internal void SendImmediate(GSRequest request) { if (_WebSocketClient != null) { lock (_WebSocketClient) { if (_WebSocketClient != null) { if (!request.Type.Equals(".AuthenticatedConnectRequest")) { if (request.GetString("requestId") == null) { request.AddString("requestId", DateTime.Now.Ticks + "_" + (_gs._requestCounter++)); } //if (request.MaxResponseTimeInMillis != _gs.RequestTimeout) { // request.AddNumber ("timeout", request.MaxResponseTimeInMillis); //} lock (_pendingRequests) { _pendingRequests.Add(request.GetString("requestId"), request); } } String requestJson = request.JSON; _gSPlatform.DebugMsg("SEND:" + requestJson); //Wrap it in a secure request if (_gs.GSPlatform.ApiSecret.Contains(":") && SessionId != null) { GSRequestData secureRequest = new GSRequestData(); secureRequest.AddString("json", requestJson); secureRequest.AddString("hmac", _gs.GSPlatform.MakeHmac(requestJson, _gs.GSPlatform.ApiSecret + "-" + SessionId)); requestJson = secureRequest.JSON; } if (_gs.GSPlatform.ApiSecret.Contains(":")) { requestJson = Encrypt(requestJson); } if (_gs.TraceMessages) { _gSPlatform.DebugMsg("SOCKET-SEND:" + requestJson); } _WebSocketClient.Send(requestJson); } } } }
private void CancelRequest(GSConnection connection, GSRequest request) { /*if (request.Durable) * { * return; * }*/ GSObject error = new GSObject("ClientError"); error.AddObject("error", new GSRequestData().AddString("error", "timeout")); error.AddString("requestId", request.GetString("requestId")); ProcessReceivedResponse(error, connection); }
private void CancelRequest(GSRequest request) { if (request.Durable) { return; } GSObject error = new GSObject("ClientError"); error.AddObject("error", new GSRequestData().AddString("error", "timeout")); error.AddString("requestId", request.GetString("requestId")); GSPlatform.ExecuteOnMainThread(() => { try { request.Complete(this, error); } catch (Exception e) { GSPlatform.DebugMsg(e.ToString()); } }); }