Пример #1
0
        public void SendNextBookingInfo(string mac, string displayName, string time, long startTime, bool forceUpdate)
        {
            // 0 = cmd, 1 = mac, 2 = next reservation name, 3 = next reservation time, 4 = start time (long), 5 = force update (bool)
            //string msg = commands[8] + "~" + mac + "~" + displayName + "~" + time + "~" + startTime + "~" + forceUpdate;
            //Console.WriteLine("Message: " + msg);

            BookingInfoUpdate biu = new BookingInfoUpdate(displayName, time, startTime, forceUpdate);

            //NetworkCommand nc = new NetworkCommand(NetworkCommand.CommandTypes.SimBookingInfoUpdate);
            // 0 = nextReservationName, 1 = nextReservationTime, 2 = startTime (long), 3 = forceUpdate (bool)
            //string msg = displayName + "~" + time + "~" + startTime + "~" + forceUpdate;
            //nc.Message = msg;
            nu.DirectMessage(biu.ToJson(), mac);
        }
Пример #2
0
        /*public void ReceiveCommand(NetworkCommand nc)
         * {
         *  switch(nc.Type)
         *  {
         *      case NetworkCommand.CommandTypes.KillKey:
         *          // Disconnects client from server
         *          nt.CloseConnection();
         *          break;
         *      case NetworkCommand.CommandTypes.StartTime:
         *          // Starts time and session
         *          // nc.Message = time   nc.Value = buffer
         *          StartTimeCmd(nc.Message, nc.Value);
         *          break;
         *      case NetworkCommand.CommandTypes.PauseTime:
         *          // Pauses session
         *          // nc.Message = time
         *          PauseTimeCmd(nc.Message);
         *          break;
         *      case NetworkCommand.CommandTypes.StopTime:
         *          // Stops session
         *          nt.Sim.TM.StopTime();
         *          break;
         *      case NetworkCommand.CommandTypes.KeepAlive:
         *          // Restarts KeepAlive thread on client side
         *          nt.RestartKeepAliveThread();
         *          break;
         *      case NetworkCommand.CommandTypes.SimBookingInfoUpdate:
         *          // Updates booking info with next scheduled session
         *          // 1 = mac, 2 = next reservation name, 3 = next reservation time, 4 = start time (long), 5 = force update (bool)
         *          // nc.Message = split string of above values
         *          // 0 = nextReservationName, 1 = nextReservationTime, 2 = startTime (long), 3 = forceUpdate (bool)
         *          string[] msg = nc.Message.Split('~');
         *          OnNextBookingUpdateEvent(new NextBookingUpdatedEventArgs(nc.MacAddress, msg[0], msg[1], long.Parse(msg[2]), bool.Parse(msg[3])));
         *          break;
         *      case NetworkCommand.CommandTypes.SimInfoUpdate:
         *          // Updates sim nickname and/or model
         *          // nc.Message = nickname   nc.Value = model
         *          OnSimInfoUpdateEvent(new SimInfoUpdateEventArgs(nc.Message, nc.Value));
         *          break;
         *      default:
         *          // Catch-all
         *          break;
         *  }
         * }*/

        public void ReceiveCommand(MessageInterface m)
        {
            switch (m.Type)
            {
            case "KillKey":
                nt.CloseConnection();
                break;

            case "TimeCommand":
                TimeCommand tc = (TimeCommand)m;
                switch (tc.SubType)
                {
                case "StartTime":
                    StartTimeCmd(tc.Time, tc.Buffer);
                    break;

                case "PauseTime":
                    PauseTimeCmd(tc.Time);
                    break;

                case "StopTime":
                    nt.Sim.TM.StopTime();
                    break;
                }
                break;

            case "Ping":
                nt.RestartKeepAliveThread();
                break;

            case "BookingInfoUpdate":
                BookingInfoUpdate biu = (BookingInfoUpdate)m;
                OnNextBookingUpdateEvent(new NextBookingUpdatedEventArgs("mac", biu.DisplayName, biu.Time, biu.StartTime, biu.ForceUpdate));
                break;

            case "SimInfoUpdate":
                SimInfoUpdate siu = (SimInfoUpdate)m;
                OnSimInfoUpdateEvent(new SimInfoUpdateEventArgs(siu.NickName, siu.Model));
                break;

            default:
                // catch-all
                break;
            }
        }