/// <summary> /// 添加TCP调用服务端 /// </summary> /// <param name="socket">TCP调用套接字</param> /// <param name="data">参数序列化数据</param> private void newServer(TmphSocket socket, TmphSubArray<byte> data) { try { var host = new TmphHost(); if (TmphDataDeSerializer.DeSerialize(data, ref host)) { TmphThreadPool.TinyPool.FastStart(server.newServerHandle, new TmphServerInfo { Socket = socket, Identity = socket.Identity, Host = host }, null, null); return; } } catch (Exception error) { TmphLog.Error.Add(error, null, true); } socket.SendStream(socket.Identity, new TmphAsynchronousMethod.TmphReturnValue { IsReturn = false }); }
/// <summary> /// 移除TCP调用服务端 /// </summary> /// <param name="socket">TCP调用套接字</param> /// <param name="data">参数序列化数据</param> private void removeServer(TmphSocket socket, TmphSubArray<byte> data) { try { var host = new TmphHost(); if (TmphDataDeSerializer.DeSerialize(data, ref host)) { socket.SendStream(socket.Identity, new TmphAsynchronousMethod.TmphReturnValue<bool> { IsReturn = true, Value = server.removeServer(host) }); return; } } catch (Exception error) { TmphLog.Error.Add(error, null, true); } socket.SendStream(socket.Identity, new TmphAsynchronousMethod.TmphReturnValue { IsReturn = false }); }
/// <summary> /// TCP调用服务端验证 /// </summary> /// <param name="socket">TCP调用套接字</param> /// <param name="data">参数序列化数据</param> private void verify(TmphSocket socket, TmphSubArray<byte> data) { try { string inputParameter = null; if (TmphDataDeSerializer.DeSerialize(data, ref inputParameter)) { var isVerify = false; if (this.isVerify == null) { if (Config.TmphTcpRegister.Default.Verify == null && !Config.TmphPub.Default.IsDebug) { TmphLog.Error.Add("TCP服务注册验证数据不能为空", false, true); } else isVerify = Config.TmphTcpRegister.Default.Verify == inputParameter; } else isVerify = this.isVerify(data); socket.IsVerifyMethod = true; socket.SendStream(socket.Identity, new TmphAsynchronousMethod.TmphReturnValue<bool> { IsReturn = true, Value = isVerify }); return; } } catch (Exception error) { TmphLog.Error.Add(error, null, true); } socket.SendStream(socket.Identity, new TmphAsynchronousMethod.TmphReturnValue { IsReturn = false }); }