/// <summary> /// 将目标Action跳转到社交服 /// </summary> /// <param name="httpGet"></param> public static async void SendDesActionToSocialServer(HttpGet httpGet) { //检查 if (SocialSession == null) { TraceLog.WriteError("SendDesActionToSocialServer error, 社交服没连接"); return; } int desActionId = 0; if (!httpGet.GetInt("DesActionId", ref desActionId)) { TraceLog.WriteError("SendDesActionToSocialServer error, 未指定目标ActionId"); return; } //执行 RequestParam param = new RequestParam(); param["ActionId"] = desActionId; foreach (var key in httpGet.Keys) { if (key == "ActionId" || key == "DesActionId") { continue; } param[key] = httpGet[key]; } string post = string.Format("?d={0}", System.Web.HttpUtility.UrlEncode(param.ToPostString())); var data = Encoding.UTF8.GetBytes(post); await SocialSession.SendAsync(data, 0, data.Length); }
/// <summary> /// /// </summary> /// <param name="routePath">Call method path, ex:className.method</param> /// <param name="param"></param> /// <param name="callback"></param> public void Call(string routePath, RequestParam param, Action <RemotePackage> callback) { int msgId = Interlocked.Increment(ref _msgId); param["MsgId"] = msgId; param["route"] = routePath; param["Sid"] = _sessionId; param["Uid"] = _userId; param["ActionId"] = 0; param["ssid"] = _proxySessionId; param["isproxy"] = true; param["proxyId"] = _proxyId; string post = string.Format("d={0}", HttpUtility.UrlEncode(param.ToPostString())); if (_client.IsSocket) { post = "?" + post; } var responsePack = new RemotePackage { MsgId = _msgId, RouteName = routePath }; responsePack.Callback += callback; PutToWaitQueue(responsePack); _client.Send(post); }
/// <summary> /// /// </summary> /// <param name="routePath">Call method path, ex:className.method</param> /// <param name="param"></param> /// <param name="callback"></param> public void Call(string routePath, RequestParam param, Action <RemotePackage> callback) { _msgId++; param["MsgId"] = _msgId; param["route"] = routePath; param["Sid"] = _sessionId; param["Uid"] = _userId; param["ActionId"] = 0; param["ssid"] = _proxySessionId; param["isproxy"] = true; param["proxyId"] = _proxyId; string post = param.ToPostString(); if (_client.IsSocket) { post = "?" + post; } var responsePack = new RemotePackage { MsgId = _msgId, RouteName = routePath }; responsePack.Callback += callback; PutToWaitQueue(responsePack); _client.Send(post); }
public async void SendLoginResult() { RequestParam param = new RequestParam(); param["ActionId"] = ActionIDDefine.CstAction33; param["msgid"] = 0; param["Ret"] = _packet.Ret; string post = string.Format("?d={0}", System.Web.HttpUtility.UrlEncode(param.ToPostString())); var data = Encoding.UTF8.GetBytes(post); await Current.SendAsync(actionGetter.OpCode, data, 0, data.Length, null); }
private void InitClient() { try { if (_client is SocketRemoteClient) { var client = _client as SocketRemoteClient; RequestParam heartParam = new RequestParam(); heartParam["ActionId"] = (int)ActionEnum.Heartbeat; string post = string.Format("?d={0}", HttpUtility.UrlEncode(heartParam.ToPostString())); client.HeartPacket = Encoding.ASCII.GetBytes(post); } } catch { } }
private void InitClient() { try { if (_client is SocketRemoteClient) { var client = _client as SocketRemoteClient; RequestParam heartParam = new RequestParam(); heartParam["ActionId"] = 0; string post = heartParam.ToPostString(); client.HeartPacket = Encoding.ASCII.GetBytes(post); } } catch { } }
protected void Init(string host, int port, int heartInterval) { _setting = GameEnvironment.Setting; var remoteEndPoint = new IPEndPoint(Dns.GetHostAddresses(host)[0], port); var settings = new ClientSocketSettings(BufferSize, remoteEndPoint); _socketRoom = new ClientSocket(settings); _socketRoom.DataReceived += new SocketEventHandler(roomSocket_DataReceived); _socketRoom.Disconnected += new SocketEventHandler(roomSocket_Disconnected); RequestParam heartParam = new RequestParam(); heartParam["ActionId"] = (int)ActionEnum.Heartbeat; heartParam["MsgId"] = 0; string post = string.Format("?d={0}", HttpUtility.UrlEncode(heartParam.ToPostString())); HeartPacket = Encoding.ASCII.GetBytes(post); _timer = new Timer(DoCheckHeartbeat, null, 1000, heartInterval); }
/// <summary> /// 异步通知路由服客户端断开 /// </summary> public async System.Threading.Tasks.Task SendSwitchClientDisconnect(GameSession session) { //转发给路由服,并通知路由服转发给大厅服 var switchSession = ServerSsMgr.GetSwitchSession(); if (switchSession == null) { return; } RequestParam interruptParam = new RequestParam(); interruptParam["ActionId"] = (int)ActionEnum.Interrupt; interruptParam["MsgId"] = 0; interruptParam["proxyId"] = session.SessionId; string post = string.Format("?d={0}", HttpUtility.UrlEncode(interruptParam.ToPostString())); var buffer = Encoding.ASCII.GetBytes(post); await switchSession.SendAsync(buffer, 0, buffer.Length); }