public static void InitialServerService(string serverProxy, string ip, int port, int heartBeatInterval) { if (mServerServices.ContainsKey(serverProxy)) { return; } ServerService service = new ServerService(); service.IP = ip; service.Port = port; service.HeartBeatInterval = heartBeatInterval; service.Service = RemoteService.CreateTcpProxy(serverProxy, ip, port, heartBeatInterval); mServerServices.Add(serverProxy, service); }
public static void SendToServer(string serverProxy, STS sts, JsonData json, Action <JsonData> callback) { ServerService service = null; if (!mServerServices.TryGetValue(serverProxy, out service)) { return; } RequestParam param = new RequestParam(); param["sts"] = (int)sts; param["data"] = json.ToJson(); param["response"] = (byte)((callback != null) ? 1 : 0); service.Service.Call("RemoteHandle", param, (result) => { var reader = new MessageStructure(result.Message as byte[]); string jsonStr = reader.ReadString(); JsonData jsonData = JsonMapper.ToObject(jsonStr); if (callback != null) { callback(jsonData); } }); }