public void Init(NetworkCommandInfo cmd, NetworkArgument arg, Action <NetBaseMsg> successCallback, Action <NetMsg <string> > failCallback, Func <NetMsg <string>, bool> exceptionCallback) { arg = arg ?? new NetworkArgument(); this.commandInfo = cmd; this.net_id = sq++; this.arg = arg; this.successCallback = successCallback; this.failCallback = failCallback; this.exceptionCallback = exceptionCallback; }
// command register routine // @id: specified a network message id // @cmd: Network command pack, includes url and message processor // @returns: a boolean value to indicate whehter the command is successfully registered or not public static bool RegisterCommand(uint id, NetworkCommandInfo info) { if (commandInfoTable.ContainsKey(id) == false && info != null) { commandInfoTable[id] = info; info.mId = id; return(true); } return(false); }
public static void Request(uint id, NetworkArgument arg, Action <NetBaseMsg> successCallback, Action <NetMsg <string> > faillCallback, Func <NetMsg <string>, bool> exceptionCallback) { if (commandInfoTable.ContainsKey(id)) { NetworkCommandInfo cmd = commandInfoTable[id]; NetworkRoutine routine = FetchIdleRoutine(); routine.Init(cmd, arg, successCallback, faillCallback, exceptionCallback); willPostQueue.Enqueue(routine); if (routine.commandInfo.isBlock) { if (blockInputHandler != null) { blockInputHandler.Invoke(true); } } UpdateManager.Add(updateObj); } }