public void SendTimeCommand(string mac, string time, string buffer, CommandTypes type) { TimeCommand tc = new TimeCommand(type, time, buffer); //NetworkCommand nc = new NetworkCommand(type, time, buffer); nu.DirectMessage(tc.ToJson(), mac); }
/*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; } }