OnPrivateMessage









How do I use On Private Message
Below are practical examples compiled from projects for learning and reference purposes

Featured Snippets


File name: ChatGui.cs Copy
342     public void OnPrivateMessage(string sender, object message, string channelName)
343     {
344         // as the ChatClient is buffering the messages for you, this GUI doesn't need to do anything here
345         // you also get messages that you sent yourself. in that case, the channelName is determinded by the target of your msg
346     }
File name: ChatClient.cs Copy
688         private void HandlePrivateMessageEvent(EventData eventData)
689         {
690             //Console.WriteLine(SupportClass.DictionaryToString(eventData.Parameters));
691
692             var message = (object)eventData.Parameters[(byte)ChatParameterCode.Message];
693             var sender = (string)eventData.Parameters[(byte)ChatParameterCode.Sender];
694
695             string channelName;
696             if (this.UserId != null && this.UserId.Equals(sender))
697             {
698                 var target = (string)eventData.Parameters[(byte)ChatParameterCode.UserId];
699                 channelName = this.GetPrivateChannelNameByUser(target);
700             }
701             else
702             {
703                 channelName = this.GetPrivateChannelNameByUser(sender);
704             }
705
706             ChatChannel channel;
707             if (!this.PrivateChannels.TryGetValue(channelName, out channel))
708             {
709                 channel = new ChatChannel(channelName);
710                 channel.IsPrivate = true;
711                 this.PrivateChannels.Add(channel.Name, channel);
712             }
713
714             channel.Add(sender, message);
715             this.listener.OnPrivateMessage(sender, message, channelName);
716         }

OnPrivateMessage 139 lượt xem

Gõ tìm kiếm nhanh...