Esempio n. 1
0
        private void send(UserAction action)
        {
            byte[] finalData;
            using (var stream = new MemoryStream())
            {

                serializer.WriteObject(stream, action);
                finalData = stream.ToArray();
            }

            var text = Encoding.UTF8.GetString(finalData);
            Console.WriteLine("Sent: {0}", text);
            file.WriteLine("send:" + text);

            Byte[] data = finalData;

            stream1.Write(data, 0, data.Length);
            stream1.Write(Encoding.UTF8.GetBytes("\n"), 0, 1);
            stream1.Flush();
        }
Esempio n. 2
0
 public void sendTurn(TurnActionEnum act,int position, long cardId,int turnNum)
 {
     UserAction action = new UserAction();
     action.Name = locname;
     action.Token = token;
     action.Action = (int)ActionTypeEnum.TURN;
     TurnAction turn=new TurnAction();
     turn.Action = (int)act;
     turn.Position = position;
     turn.CardId = cardId;
     turn.TurnNumber = turnNum;
     action.TurnAction = turn;
     send(action);
 }
Esempio n. 3
0
 public void sendTurnAction(int turnNumber, long cardId, int position)
 {
     UserAction action = new UserAction();
      action.Name = locname;
      action.Token = token;
      action.Action = (int)ActionTypeEnum.TURN;
      TurnAction ta = new TurnAction();
      ta.Action = (int)TurnActionEnum.turn;
      ta.CardId = cardId;
      ta.Position = position;
      ta.TurnNumber = turnNumber;
      action.TurnAction = ta;
      send(action);
 }
Esempio n. 4
0
 public void sendSurrender(int turnNumber)
 {
     UserAction action = new UserAction();
     action.Name = locname;
     action.Token = token;
     action.Action = (int)ActionTypeEnum.TURN;
     TurnAction ta = new TurnAction();
     ta.Action=(int)TurnActionEnum.surrender;
     ta.TurnNumber=turnNumber;
     action.TurnAction = ta;
     send(action);
 }
Esempio n. 5
0
 public void sendSearch()
 {
     UserAction action = new UserAction();
     action.Name = locname;
     action.Token = token;
     action.Action = (int)ActionTypeEnum.SEARCH;
     send(action);
 }
Esempio n. 6
0
 public void sendConnect(String name, String pass)
 {
     UserAction action = new UserAction();
     action.Name = name;
     action.Action = (int)ActionTypeEnum.CONNECT; ;
     ConnectAction connect = new ConnectAction();
     connect.Pass = pass;
     action.ConnectAction = connect;
     send(action);
 }
Esempio n. 7
0
 public void createUser(String name, String pass, int side)
 {
     UserAction action = new UserAction();
     action.Name = name;
     action.Action = (int)ActionTypeEnum.CREATE_USER;
     CreateUserAction connect = new CreateUserAction();
     connect.Name = name;
     connect.Pass = pass;
     connect.Side = side;
     action.CreateUserAction = connect;
     send(action);
 }
Esempio n. 8
0
 public void cardRequest()
 {
     UserAction action = new UserAction();
     action.Name = locname;
     action.Token = token;
     action.Action = (int)ActionTypeEnum.GET_CARD_INFO; ;
     CardInfoAction act=new CardInfoAction();
     send(action);
 }