public void ProcessCommand(string text, NetConnection sender) { var args = new List <string>(); CommandParsing.ParseArguments(text, args); if (args.Count == 0) { return; } string cmd = args[0]; try { IClientCommand command = AvailableCommands[cmd]; args.RemoveAt(0); var client = IoCManager.Resolve <ISS14Server>().GetClient(sender); command.Execute(this, client, args.ToArray()); } catch (KeyNotFoundException) { SendConsoleReply(string.Format("Unknown command: '{0}'", cmd), sender); } catch (Exception e) { SendConsoleReply(string.Format("There was an error while executing the command: {0}", e.Message), sender); } }
public void ProcessCommand(MsgConCmd message) { string text = message.Text; INetChannel sender = message.MsgChannel; var args = new List <string>(); CommandParsing.ParseArguments(text, args); if (args.Count == 0) { return; } string cmd = args[0]; try { IClientCommand command = AvailableCommands[cmd]; args.RemoveAt(0); command.Execute(this, sender, args.ToArray()); } catch (KeyNotFoundException) { SendConsoleReply(string.Format("Unknown command: '{0}'", cmd), sender); } catch (Exception e) { SendConsoleReply(string.Format("There was an error while executing the command: {0}", e.Message), sender); } }
public void OnDataReceived(ProtocolBase <TTransportDestType> protocol, IClientCommand action, Type actiontype) { var data = protocol.ProtocolName != _protocol.ProtocolName ? _protocol.CleanData(protocol.GetDataToSend()) : protocol.GetBody(); var obj = DeSerializer.Deserialize(actiontype, data); action.Execute(this, obj as IClientCommand); }
private void ReceiveClientCommand(NetPacketReader reader, int clientNetId) { IClientCommand command = m_clientCommandDict[(NetworkToServerDataType)reader.GetByte()]; if (command.m_DataType != NetworkToServerDataType.SET_POSITION) { Console.WriteLine("CC: " + command.m_DataType); } try { command.Execute(reader, clientNetId); } catch (Exception e) { Console.WriteLine(e); } }