Exemple #1
0
        public Packet ToPacket(string line)
        {
            Dictionary <string, object> map = JsonConvert.DeserializeObject <Dictionary <string, object> >(line, serializerSetting);

            Request        request        = map["request"] != null ? (Request)Enum.Parse(typeof(Request), (string)map["request"]) : Request.DUMMY;
            GameInfoToSend gameInfoToSend = null;

            if (map["gameInfo"] != null)
            {
                gameInfoToSend = JsonConvert.DeserializeObject <GameInfoToSend>(JsonConvert.SerializeObject(map["gameInfo"], serializerSetting), serializerSetting);
                if (map["gameSetting"] != null)
                {
                    GameSetting gameSetting = JsonConvert.DeserializeObject <GameSetting>(JsonConvert.SerializeObject(map["gameSetting"], serializerSetting), serializerSetting);
                    return(new Packet(request, gameInfoToSend, gameSetting));
                }
                else
                {
                    return(new Packet(request, gameInfoToSend));
                }
            }
            else if (map["talkHistory"] != null)
            {
                List <TalkToSend> talkHistoryList    = ToTalkList(JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(JsonConvert.SerializeObject(map["talkHistory"], serializerSetting), serializerSetting));
                List <TalkToSend> whisperHistoryList = ToTalkList(JsonConvert.DeserializeObject <List <Dictionary <string, string> > >(JsonConvert.SerializeObject(map["whisperHistory"], serializerSetting), serializerSetting));
                return(new Packet(request, talkHistoryList, whisperHistoryList));
            }
            else
            {
                return(new Packet(request));
            }
        }
Exemple #2
0
 /// <summary>
 /// Create packet with game inforamtion and game setting.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="gameInfoToSend"></param>
 /// <param name="gameSetting"></param>
 public Packet(Request request, GameInfoToSend gameInfoToSend, GameSetting gameSetting)
 {
     Request     = request;
     GameInfo    = gameInfoToSend;
     GameSetting = gameSetting;
 }
Exemple #3
0
 /// <summary>
 /// Create packet with game information.
 /// </summary>
 /// <param name="request"></param>
 /// <param name="gameInfoToSend"></param>
 public Packet(Request request, GameInfoToSend gameInfoToSend)
 {
     Request  = request;
     GameInfo = gameInfoToSend;
 }