Esempio n. 1
0
        protected override void websocket_Opened(object sender, EventArgs e)
        {
            base.websocket_Opened(sender, e);

            ReqJoinGameContent content = new ReqJoinGameContent() { gamename = GlobalVars.LiarDiceGameName, userid=GlobalVars.userid};
            ReqJoinGame joinGameRequest = new ReqJoinGame(content);

            List<Type> knowTypes = new List<Type>();
            knowTypes.Add(typeof(ReqJoinGameContent));

            string msg = JsonHelper.ObjectToJson(typeof(ReqJoinGame), knowTypes, joinGameRequest);
            websocket.Send(msg);

            //string jsonStr = @"{code:100, content:{userid:435234, gameName:'liardice'}}";
            //ReqJoinGame sdf = JsonHelper.JsonToObject(typeof(ReqJoinGame), knowTypes, jsonStr) as ReqJoinGame;
            //ReqJoinGameContent sd = sdf.content;
        }
Esempio n. 2
0
        public override void Disconnect()
        {
            ReqJoinGameContent content = new ReqJoinGameContent() { gamename = GlobalVars.LiarDiceGameName, userid = GlobalVars.userid };
            ReqCancelJoinGame joinGameRequest = new ReqCancelJoinGame(content);

            List<Type> knowTypes = new List<Type>();
            knowTypes.Add(typeof(ReqJoinGameContent));

            string msg = JsonHelper.ObjectToJson(typeof(ReqCancelJoinGame), knowTypes, joinGameRequest);

            try
            {
                websocket.Send(msg);
                base.Disconnect();
            }
            catch (Exception)
            {
                MessageBox.Show("网络异常.");
                return;
            }
        }
Esempio n. 3
0
 public ReqCancelJoinGame(ReqJoinGameContent p_content)
 {
     code = GlobalVars.RequestCode.CancelJoinCode;
     content = p_content;
 }
Esempio n. 4
0
 public ReqCancelJoinGame()
 {
     code = GlobalVars.RequestCode.CancelJoinCode;
     content = new ReqJoinGameContent();
 }