Exemplo n.º 1
0
        private void SendFirstMessage()
        {
            string  content      = UserName + ":" + this._password;
            Message firstMessage = new Poker.Shared.Message(content, MessageType.PlayerSigningIn);

            this.SendMessage(firstMessage);
        }
Exemplo n.º 2
0
 private void CasinoUpdateMessage(Poker.Shared.Message message)
 {
     if (message.MessageType == MessageType.CasinoUpdate)
     {
         ViewModel_Casino vm = JsonConvert.DeserializeObject <ViewModel_Casino>(message.Content);
         this.UpdateModel(vm);
     }
 }
Exemplo n.º 3
0
 public void AppendTextBox(RichTextBox txtbox, Poker.Shared.Message value)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <RichTextBox, Poker.Shared.Message>(AppendTextBox), new object[] { txtbox, value });
         return;
     }
     txtbox.Text += value.Content;
 }
Exemplo n.º 4
0
        private void BetEventMessage(Poker.Shared.Message message)
        {
            string[] arr     = message.Content.Split(':');
            string   tableno = arr[0];

            lock (this.BetEvent)
            {
                this.BetEvent[tableno].Invoke(message);
            }
        }
Exemplo n.º 5
0
 public void SetReceivedMessage(Poker.Shared.Message value)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <Poker.Shared.Message>(SetReceivedMessage), new object[] { value });
         return;
     }
     Console.WriteLine("Inside SetReceivedMessage function from threa " + Thread.CurrentThread.Name);
     this.txtReceiever.AppendText(value.MessageType.ToString() + "-- Content Size -> " + value.Content.Length.ToString());
     this.txtReceiever.AppendText(Environment.NewLine);
 }
Exemplo n.º 6
0
 public void AppendTextBox(Poker.Shared.Message value)
 {
     if (this.InvokeRequired)
     {
         this.Invoke(new Action <Poker.Shared.Message>(AppendTextBox), new object[] { value });
         return;
     }
     // this.textBox1.Text += value;
     this.textBox1.AppendText(value.UserName + " : " + value.MessageType + ":" + value.Content);
     this.textBox1.AppendText(Environment.NewLine);
 }
Exemplo n.º 7
0
        public void ProcessMessage(Poker.Shared.Message message)
        {
            if (message.MessageType == MessageType.PlayerBankBalance)
            {
                string  temp        = message.Content;
                decimal total_money = Convert.ToDecimal(temp.Split(';')[0]);
                decimal avail_money = Convert.ToDecimal(temp.Split(';')[1]);

                this.update(message.UserName, total_money, avail_money);
            }
        }
Exemplo n.º 8
0
        public void SendTableJoinMessage(string TableNo, short SeatNo, decimal ChipCount)
        {
            string content = TableNo + ":" + SeatNo + ":" + ChipCount;

            Poker.Shared.Message m = new Poker.Shared.Message(content, MessageType.PlayerJoiningGame);
            if (_user != null)
            {
                _user.SendMessage(m);
            }
            // Console.WriteLine("MessageFactory:Sent TableJoin Message for user " + this._user.UserName);
        }
Exemplo n.º 9
0
        public void SendReceiveBetMessage(string TableNo, decimal ChipCount, string gameStage)
        {
            string content = TableNo + ":" + ChipCount + ":" + gameStage;

            Poker.Shared.Message m = new Poker.Shared.Message(content, MessageType.PlayerAction);
            if (_user != null)
            {
                _user.SendMessage(m);
            }
            Console.WriteLine("MessageFactory:Sent ReceiveBet Message for user " + this._user.UserName);
        }
Exemplo n.º 10
0
        public Message Process(StreamReader reader)
        {
            Poker.Shared.Message m = null;
            String line            = reader.ReadLine();

            if (line != null)
            {
                m = Poker.Shared.Message.DeSerialize(line);
            }

            return(m);
        }
Exemplo n.º 11
0
 public static Message Process(StreamReader reader)
 {
     Poker.Shared.Message m = null;
     try
     {
         String line = reader.ReadLine();
         m = Poker.Shared.Message.DeSerialize(line);
     }
     catch (Exception e)
     {
         Console.WriteLine(e.Message);
     }
     return(m);
 }
Exemplo n.º 12
0
        private void PlayerBankBalanceMessage(Poker.Shared.Message message)
        {
            if (message.MessageType == MessageType.PlayerBankBalance)
            {
                string  temp        = message.Content;
                decimal total_money = Convert.ToDecimal(temp.Split(';')[0]);
                decimal avail_money = Convert.ToDecimal(temp.Split(';')[1]);
                this._casinoModel.BankBalance = new ViewModel_SelectMoney();

                this._casinoModel.BankBalance.TotalMoney     = total_money;
                this._casinoModel.BankBalance.AvailableMoney = avail_money;

                this.updateBankBalance();
            }
        }
Exemplo n.º 13
0
        public void ProcessMessage(Poker.Shared.Message message)
        {
            if (message == null)
            {
                return;
            }
            switch (message.MessageType)
            {
            case MessageType.TableSendHoleCards:
                OnReceiveHoleCards(PConvert.ToHoleCards(message));
                break;

            case MessageType.TableSendFlop:
                OnReceiveFlop(PConvert.ToFlop(message));
                break;

            case MessageType.TableSendTurn:
                OnReceiveTurn(PConvert.ToSingleCard(message));
                break;

            case MessageType.TableSendRiver:
                OnReceiveRiver(PConvert.ToSingleCard(message));
                break;

            case MessageType.PlayerActionRequestBet:
                OnReceiveRequestBet(message);
                break;

            case MessageType.PlayerAction:
                OnReceivePlayerAction(message);
                break;

            case MessageType.GameUpdate:
                string[] state = message.Content.Split(':');
                if (state[0] == "Starting")
                {
                    OnReceiveGameStart(Convert.ToInt16(state[1]));
                }
                if (state[0] == "Ending")
                {
                    OnReceiveGameEnd();
                }
                break;

            default:
                throw new Exception("Not sure what message is this");
            }
        }
Exemplo n.º 14
0
 public void ProcessMessage(Poker.Shared.Message message)
 {
     Console.WriteLine("Incoming message for " + message.UserName + " " + message.MessageType + " size=" + message.Content.Length.ToString());
     lock (this.syncObj)
     {
         if ((message != null) && (_dict.ContainsKey(message.MessageType)))
         {
             _dict[message.MessageType](message);
         }
         if ((message != null) && (_dict.ContainsKey(MessageType.GeneralPurpose)))
         {
             _dict[MessageType.GeneralPurpose](message);
         }
         if ((message != null) && (message.MessageType == MessageType.ServerReady))
         {
             _user.ServerReady = true;
         }
     }
 }
Exemplo n.º 15
0
 public void ProcessMessage(Poker.Shared.Message m)
 {
     if (m.MessageType == MessageType.CasinoUpdate)
     {
         CasinoUpdateMessage(m);
     }
     else if (m.MessageType == MessageType.PlayerBankBalance)
     {
         PlayerBankBalanceMessage(m);
     }
     else if (m.MessageType == MessageType.TableUpdate)
     {
         TableUpdateMessage(m);
     }
     else if (m.MessageType == MessageType.PlayerActionRequestBet)
     {
         BetEventMessage(m);
     }
     else if (m.MessageType == MessageType.TableSendHoleCards)
     {
         CardEventMessage(m);
     }
     else if (m.MessageType == MessageType.TableSendFlop)
     {
         CardEventMessage(m);
     }
     else if (m.MessageType == MessageType.TableSendTurn)
     {
         CardEventMessage(m);
     }
     else if (m.MessageType == MessageType.TableSendRiver)
     {
         CardEventMessage(m);
     }
     else if (m.MessageType == MessageType.PlayerAction) // when a player on a table bets/calls/folds, that message is received by all users on the table
     {
         PlayeActionMessage(m);
     }
 }
Exemplo n.º 16
0
        public void TableUpdateMessage(Poker.Shared.Message message)
        {
            if (message.MessageType == MessageType.TableUpdate)
            {
                ViewModel_Table vm_table = JsonConvert.DeserializeObject <ViewModel_Table>(message.Content);

                vm_table.UserName     = this.UserName;
                vm_table.UserServices = this._casinoModel.UserServices;
                if (_casinoModel != null)
                {
                    _casinoModel.Replace(vm_table);
                }
                Console.WriteLine("Recevied table update message for TableNo -- " + vm_table.TableNo);
                if ((_detailPanelModel != null) && (_detailPanelModel.TableNo == vm_table.TableNo))
                {
                    SetDetailPanel(vm_table.TableNo);
                }
                else
                {
                    SetDetailPanel(vm_table.TableNo);
                }
            }
        }
Exemplo n.º 17
0
 private void RaiseEvent(Poker.Shared.Message message)
 {
     PlayerAction?.Invoke(this, message);
 }