private string SendRequest(QueueRequest queRequest) { queRequest.Running = true; queRequest.BeforeRequest?.Invoke(); var seq = client.SendRequest(queRequest.Body, queRequest.Subcmd, queRequest.Response, queRequest.Completed, queRequest.RequestCmd, ""); queRequest.AfterRequest?.Invoke(seq); return(seq); }
private string PushRequest(QueueRequest queRequest, Queue <QueueRequest> queue) { var callback = queRequest.Completed; Action <ResponseEvent> requestCompleted = (ResponseEvent seq) => { callback(seq); queRequest.Running = false; queue.Dequeue(); QueueLoop(queue); }; queRequest.Completed = requestCompleted; queue.Enqueue(queRequest); return(QueueLoop(queue)); }
public string Send(ByteString body, int subcmd, NetResponseCallback response, Action <ResponseEvent> callback) { // 第一层 cmd:通用连接 | 帧同步连接 var requestCmd = "comm_cmd"; if (client.Socket.Id == (int)ConnectionType.Relay) { requestCmd = "relay_cmd"; } var queRequest = new QueueRequest { Body = body, Subcmd = (int)subcmd, Completed = callback, RequestCmd = requestCmd, Running = false, Response = response }; // CheckLogin 队列化 if (subcmd == (int)ClientSendServerReqWrap2Cmd.ECmdCheckLoginReq) { queRequest.BeforeRequest = () => { CheckLoginStatus.SetStatus(CheckLoginStatus.StatusType.Checking); }; queRequest.AfterRequest = (seq) => { // Debugger.Log("CHECKLOGIN", seq); }; } ; // 房间操作队列化 var queue = BaseNetUtil._roomCmd.Contains((ClientSendServerReqWrap2Cmd)subcmd) ? BaseNetUtil._roomQueue : BaseNetUtil._checkLoginQueue; return(queue.Count == 0 ? SendRequest(queRequest) : PushRequest(queRequest, queue)); }