/// <summary> /// 向指定会话发送消息 /// </summary> /// <param name="connectionID"></param> public void SendData(Int32 servicePort, Int64 connectionID, byte[] datas) { if (!this.ServerItems.ContainsKey(servicePort)) { return; } FromServer fsi = this.ServerItems[servicePort]; fsi.SendData(connectionID, datas); }
/// <summary> /// 通道关闭 /// </summary> public void TunnelClose(Int32 servicePort) { if (!this.ServerItems.ContainsKey(servicePort)) { return; } FromServer fsi = this.ServerItems[servicePort]; fsi.TunnelClose(); }
/// <summary> /// 关闭会话 /// </summary> /// <param name="connectionID"></param> public void CloseSession(Int32 servicePort, Int64 connectionID) { if (!this.ServerItems.ContainsKey(servicePort)) { return; } FromServer fsi = this.ServerItems[servicePort]; fsi.CloseSession(connectionID); }
protected override void OnDisconnected(CloseReason reason) { FromServer fsi = this.Monitor as FromServer; if (fsi == null) { return; } AgentServer.Instance.SendDisconnect(fsi.ServicePort, this.ConnectionID); }
protected override void OnReceived(Packet packet) { FromServer fsi = this.Monitor as FromServer; if (fsi == null) { return; } byte[] datas = packet.Read(); AgentServer.Instance.SendDatas(fsi.ServicePort, this.ConnectionID, datas); }
protected override void OnConnected() { FromServer fsi = this.Monitor as FromServer; if (fsi == null) { return; } if (!AgentServer.Instance.SendConnect(fsi.ServicePort, this.ConnectionID)) { this.Close(CloseReason.RemoteClose); } }
public void Start() { var config = ConfigHelper.GetInstance <AgentConfigInfo>(); if (config.AgentPortMap == null || config.AgentPortMap.Length <= 0) { throw new Exception("config AgentPortMap error"); } PortMap pm; FromServer fsi; for (int i = 0; i < config.AgentPortMap.Length; i++) { pm = config.AgentPortMap[i]; fsi = new FromServer(pm.ServicePort); fsi.Start("0.0.0.0", pm.FromPort); ServerItems.Add(pm.ServicePort, fsi); } }