private void GetCardResponse(DataTransferModel messageObject)
 {
     var card = GetCard();
     var cardJson = JsonConvert.SerializeObject(card);
     var playerNumber = messageObject.SocketNumber;
     _players[playerNumber - 1].Hand.Add(card);
     _socketServer.SendMessageById(messageObject.ClientId, messageObject.DataTitle, cardJson);
 }
 public void SendEncoded(string dataType, string dataTitle, string data)
 {
     var dataObj = new DataTransferModel
     {
         DataType = dataType,
         DataTitle = dataTitle,
         Data = data
     };
     var encodedData = Encode(JsonConvert.SerializeObject(dataObj));
     var bytes = Convert.FromBase64String(encodedData);
     _socket.Send(bytes);
 }
 protected override void HandleMessage(DataTransferModel messageObject)
 {
     switch (messageObject.DataTitle)
     {
         case "addplayer":
             AddPlayer(messageObject);
             break;
         case "getcard":
             GetCardResponse(messageObject);
             break;
         case "player1":
             _socketServer.SendMessageBySocketNumber(1, "player1", messageObject.Data);
             break;
         case "player2":
             _socketServer.SendMessageBySocketNumber(2, "player2", messageObject.Data);
             break;
     }
 }
 /// <summary>
 /// This function is automatically called by the socket server when a data type of "message" is received
 /// </summary>
 /// <param name="messageObject">The object containing message data</param>
 protected abstract void HandleMessage(DataTransferModel messageObject);
 private void AddPlayer(DataTransferModel messageObject)
 {
     if (_players.Count >= MaxPlayers)
         _players.RemoveAt(0);
     _players.Add(new Player {Number = messageObject.SocketNumber});
 }
 private void HandleData(DataTransferModel jsonObject)
 {
     try
     {
         switch (jsonObject.DataType.ToLowerInvariant())
         {
             case "broadcast":
                 BroadcastMessage(jsonObject.Data);
                 break;
             case "guid":
                 SendGuid(jsonObject.ClientId);
                 break;
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine("exception");
     }
 }