Пример #1
0
 private async Task Write(IClientConnection clientConnection, IMessage message)
 {
     try
     {
         Console.WriteLine("Writing message type " + message.MessageType + " to user: "******"Error in the Write() method + " + e.Message);
     }
 }
Пример #2
0
        private async Task NotifyNewUserOfOtherConnections(IClientConnection connection)
        {
            await Task.Run(async() =>
            {
                var connections = _clientsHolder.ClientConnections.TakeCopy();

                foreach (var conn in connections)
                {
                    Console.WriteLine("notfying new user: "******" about existing user: " + conn.UserId);
                    var msg = new NewUserOnlineMessage {
                        UserId = (ushort)conn.UserId
                    };
                    await _networkDataService.WriteAndEncodeMessageWithHeader(msg, connection.Stream);
                }
            });
        }
 public async Task SendMessage(IMessage message)
 {
     await _networkDataService.WriteAndEncodeMessageWithHeader(message, _currentUser.NetworkStream);
 }