コード例 #1
0
        private void RoutePeerToPeerMessage(object sender, ChatMessage msg)
        {
            ChatClientWrapper client;

            if (this.participants.TryGetValue(msg.DestinatarId, out client))
            {
                // destinatar client was found in list
                client.AsHandler().HandleChatMessage(sender, msg);
            }
            else
            {
                // destinatar was not found in list
                // we try to contact emitter back and signall the issue
                client = ChatClientWrapper.TryWrap(sender);

                // try to use it's handler implementation
                var errorHandler = client.AsHandler();

                if (errorHandler != null)
                {
                    errorHandler.HandleErrorMessage(
                        this,
                        ChatMessage.PeerToPeer(
                            $"Destinatar '{msg.DestinatarId}' doesn't exist",
                            msg.DestinatarId));
                }
            }
        }
コード例 #2
0
        public void HandleConnectRequest <T>(T client)
            where T : IChatParticipant, IChatMessageEmitter, IChatMessageHandler
        {
            if (client == null)
            {
                // we don't accept null clients
                return;
            }

            if (this.participants.ContainsKey(client.Id))
            {
                // client already connected
                return;
            }

            // add client to the list of connected clients
            this.participants.Add(client.Id, ChatClientWrapper.Wrap(client));

            // attach to client messaging
            client.OnChatEvent += this.Client_OnChatEvent;

            this.NotifyGroupOnNewConnection(client);
        }
コード例 #3
0
 public ChatClientMessageWrapper(ChatClientWrapper ccw, string message)
     : base(ccw.UniqueID, ccw.Name, ccw.PermLevel, ccw.CanSeeIPs)
 {
     this.message = message;
 }
コード例 #4
0
ファイル: TestForm.cs プロジェクト: thexbasic/Async_Chat
 /// <summary>
 /// Another client joined
 /// </summary>
 /// <param name="c"></param>
 void client_ClientJoinedEvent(ChatClientWrapper c)
 {
     listBox_clients.Items.Add(c.Name);
     Log("CONNECTED: " + c.Name);
 }
コード例 #5
0
ファイル: TestForm.cs プロジェクト: thexbasic/Async_Chat
 /// <summary>
 /// A client got updated.. permissions, name w/e
 /// </summary>
 /// <param name="c"></param>
 void client_ClientUpdateEvent(ChatClientWrapper c)
 {
     Log("UPDATE: " + c.UniqueID);
 }