Exemplo n.º 1
0
 internal void RemoveFromMachineList(SlaveInfo Slave)
 {
     lock (MasterServer.Connections)
         try
         {
             Invoke(new Action(() => CheLisBox_ConnectedMachines.Items.Remove(Slave.ToString())));
         }
         catch { }
 }
Exemplo n.º 2
0
 internal void ActivateForTappedCard(SlaveInfo Slave)
 {
     lock (MasterServer.Connections)
         try
         {
             Invoke(new Action(() => CheLisBox_ConnectedMachines.SetItemChecked(CheLisBox_ConnectedMachines.Items.IndexOf(Slave.ToString()), true)));
         }
         catch { }
 }
Exemplo n.º 3
0
        private void NewConnection(JSONServerSocket e)
        {
            JSONResponse <SlaveInfo> NewConnectionInfo = e.TransmitJSONCommand <PlayGameModel, SlaveInfo>(new JSONAction <PlayGameModel> {
                ActionName = "GetSlaveInfo", ActionData = new PlayGameModel {
                    GUID = AttendantConsole.GUIDGameSelection
                }
            });

            Thread.Sleep(100);
            SlaveInfo Info = NewConnectionInfo.ActionData;

            Info.Connection = e;
            lock (Connections)
                Connections.Add(Info.ToString(), Info);
            AttendantConsole.Log($"{Info} Has Connected.");
            AttendantConsole.AddToMachineList(Info);
        }
Exemplo n.º 4
0
 internal void MarkGameAsStoped(SlaveInfo Slave)
 {
     lock (MasterServer.Connections)
         try
         {
             Invoke(new Action(() =>
             {
                 RunningMachines.Remove(Slave.ToString());
                 LisBox_RunningMachines.Items.Remove(Slave.ToString());
                 if (RunningMachines.Count == 0)
                 {
                     Bu_Start.Enabled = true;
                     Bu_Stop.Enabled  = false;
                 }
             }));
         }
         catch { }
 }
Exemplo n.º 5
0
        private JSONResponse <dynamic> OnMessageReceived(JSONAction <dynamic> Message)
        {
            switch (Message.ActionName)
            {
            case "NotifyOfGamesEnd":
            {
                SlaveInfo Data = Message.DynamicAutoCast <SlaveInfo>().ActionData;
                AttendantConsole.MarkGameAsStoped(Data);
                AttendantConsole.Log($"{Data} Has stopped its game.");
                JSONResponse <dynamic> Return = new JSONResponse <dynamic>()
                {
                    ActionName = Message.ActionName, ActionData = new { }, RequestStatus = JSONResponseStatus.Success
                };
                Console.WriteLine($"Returing with:\n{Return}");
                return(Return.ToDynamic());
            }

            case "CardTapped":
            {
                SlaveInfo Data = Message.DynamicAutoCast <SlaveInfo>().ActionData;
                AttendantConsole.ActivateForTappedCard(Message.DynamicAutoCast <SlaveInfo>().ActionData);
                AttendantConsole.Log($"{Data} Has detected a card tap. Setting to active start.");
                JSONResponse <dynamic> Return = new JSONResponse <dynamic>()
                {
                    ActionName = Message.ActionName, ActionData = new { }, RequestStatus = JSONResponseStatus.Success
                };
                Console.WriteLine($"Returing with:\n{Return}");
                return(Return.ToDynamic());
            }

            default:
            {
                JSONResponse <dynamic> Return = new JSONResponse <dynamic>()
                {
                    ActionName = Message.ActionName, ActionData = Message.ActionData, Message = "The Client has failed to find the requested action.", RequestStatus = JSONResponseStatus.ActionNotFound
                };
                Console.WriteLine($"Returing with:\n{Return}");
                return(Return);
            }
            }
        }