Ejemplo n.º 1
0
 public void NotifyClient(GameHubConnectionClient client, GameHubMessage message)
 {
     try
     {
         if (client.Connection.Connected)
         {
             GameHubConnectivity.SendMessageToClient(client, message);
         }
     }
     catch
     {
         return;
     }
 }
Ejemplo n.º 2
0
        private void HandleClientConnect(CancellationToken token)
        {
            Task.Factory.StartNew(async() =>
            {
                try
                {
                    if (Server.Pending())
                    {
                        var client        = await Server.AcceptTcpClientAsync();
                        var gameHubClient = new GameHubConnectionClient
                        {
                            Connection = client
                        };

                        lock (_clientsLock)
                        {
                            _clients.Add(gameHubClient);
                        }

                        GameHubConnectivity.Subscribe(client, MessageQueue, TimeSpan.FromMilliseconds(200), token);

                        var message = new GameHubMessage
                        {
                            SenderGamePort = ((IPEndPoint)Server.LocalEndpoint).Port,
                            Text           = "Welcome to the GameHub Server. I hope you enjoy yourself",
                            Status         = EMessageType.InitialServerConnection
                        };

                        NotifyClient(gameHubClient, message);
                    }
                }
                catch
                {
                    return;
                }
            }, token);
        }
Ejemplo n.º 3
0
 public static void SendMessageToClient(GameHubConnectionClient client, GameHubMessage message)
 {
     SendMessageToClient(client.Connection, message);
 }