GameChat Docs
  • Overview
  • Getting Started
  • Basics
    • Game Chat (V2)
      • Game Chat(한국어)
        • Game Chat 사용 준비
        • Game Chat 시작
          • Game Chat 운영 및 관리
          • Unity SDK
        • OpenAPI
          • 채널 생성
          • 채널 수정
          • 채널 삭제
        • Game Chat 리소스 관리
        • Game Chat 릴리즈 노트
      • Game Chat(English)
        • Prerequisites for using Game Chat
        • Getting started with Game Chat
          • Game Chat operation and management
          • Unity SDK
        • OpenAPI
          • Channel creation API
          • Channel edit
          • Channel deletion API
        • Game Chat resource management
        • Game Chat release notes
      • Game Chat(日本語)
        • Game Chat を使用する前に
        • Game Chat を開始する
          • Game Chat の運用と管理
          • Unity SDK
        • OpenAPI
          • チャンネル作成API
          • チャネルの修正
          • チャンネル削除API
        • Game Chatのリソース管理
        • Game Chat のリリースノート
      • Game Chat(中文)
        • Game Chat使用前准备
        • 启动Game Chat
          • Game Chat运营和管理
          • Unity SDK
        • Open API
          • 频道创建API
          • 修改频道
          • 频道删除API
        • Game Chat资源管理
        • Game Chat版本注释
    • Game Chat (V3)
      • Game Chat(한국어)
        • V3 사용 시작
          • Unity SDK 설치
          • 초기화
          • 로그인
          • 채널
          • 메시지
          • 이벤트
          • 친구
          • 푸시
          • 가져오기&내보내기
          • 고정 메시지
          • 외부연동
          • 사용예제
          • Troubleshooting
      • Game Chat(English)
        • Start using V3
          • Install Unity SDK
          • Initialization
          • Login
          • Channel
          • messages
          • Events
          • Friendship
          • Push
          • Import and export
          • Pinned message
          • External integration
          • Usage examples
          • Troubleshooting
      • Game Chat(日本語)
        • V3の使用を開始
          • Unity SDK のインストール
          • 初期化
          • ログイン
          • チャンネル
          • メッセージ
          • イベント
          • 友達
          • プッシュ
          • インポート&エクスポート
          • 固定メッセージ
          • 外部連携
          • ユースケース
          • Troubleshooting
      • Game Chat(中文)
        • 开始使用V3
          • Unity SDK 安装
          • 初始化
          • 登录
          • 频道
          • 消息功能
          • 事件
          • 好友
          • 推送
          • 导入与导出
          • 固定消息
          • 外部集成
          • 使用示例
          • Troubleshooting
Powered by GitBook
On this page
  • Events
  • Main event types
  • Connect and disconnect event handler
  1. Basics
  2. Game Chat (V3)
  3. Game Chat(English)
  4. Start using V3

Events

Events

Ncloud Chat provides the Event Listener function, which can handle diverse events that occur from the client side. With this function, you can monitor many circumstances occurring in the chat application in real time and respond to them properly. The following describes the main events and how to handle events.

Main event types

  1. Receive message: triggered when a new message is received.

  2. Delete message: triggered when a message is deleted.

  3. Error message: triggered when an error occurs.

  4. Connected: triggered when successfully connected to the server.

  5. Disconnected: triggered when disconnected from the server.

  6. Typing start and end: triggered when you start or end typing.

  7. Add and remove members: triggered when a user is added or removed.

  8. Member suspension and withdrawal: triggered when a user gets suspended in the channel or withdraws from the channel.

The following shows how to listen for events on the client side.

nc.dispatcher.onMessageReceived += message =>
{
    Console.WriteLine("received a new message: ", message);
}

Connect and disconnect event handler

With event handlers, you can receive diverse events, and implement the logic you need. The following codes show how to connect and disconnect the event handler for each event.

// Message Received
nc.dispatcher.onMessageReceived += e =>
{
    Console.WriteLine("onMessageReceived: ", e);
};

// Message Deleted
nc.dispatcher.onMessageDeleted += e =>
{
    Console.WriteLine("onMessageDeleted: ", e);
};

// Error Message
nc.dispatcher.onErrorReceived += e =>
{
    Console.WriteLine("[CloudChatSample] onErrorReceived: ", e);
};

// Connection Successful
nc.dispatcher.onConnected += e =>
{
    Console.WriteLine("[CloudChatSample] Connected to server with id: {0} ", e);
};

// Connection Closed
nc.dispatcher.onDisconnected += e =>
{
    Console.WriteLine("Disconnected");
};

// When Typing Starts
nc.dispatcher.onStartTyping += e =>
{
    Console.WriteLine("onStartTyping: ", e);
};

// When Typing Ends
nc.dispatcher.onStopTyping += e =>
{
    Console.WriteLine("onStopTyping: ", e);
};

// When a User Subscribes to the Channel
nc.dispatcher.onMemberAdded += e =>
{
    Console.WriteLine("onMemberAdded: ", e);
};

// When a User Unsubscribes from the Channel
nc.dispatcher.onMemberLeft += e =>
{
    Console.WriteLine("[CloudChatSample] onMemberLeft: ", e);
};

// When a User is Suspended from the Channel
nc.dispatcher.onMemberBanned += e =>
{
    Console.WriteLine("[CloudChatSample] onMemberBanned: ", e);
};

// When a User Leaves the Channel
nc.dispatcher.onMemberDeleted += e =>
{
    Console.WriteLine("[CloudChatSample] onMemberDeleted: ", e);
};

nc.dispatcher.onSubscriptionUpdated += e =>
{
    Console.WriteLine("[CloudChatSample] onSubscriptionUpdated: ", e);
};

With Event Listener, the user of Ncloud Chat can identify the change of the chat environment in real time and respond to it properly.

PreviousmessagesNextFriendship

Last updated 6 months ago