コード例 #1
0
        /// <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);
        }
コード例 #2
0
        /// <summary>
        /// 通道关闭
        /// </summary>
        public void TunnelClose(Int32 servicePort)
        {
            if (!this.ServerItems.ContainsKey(servicePort))
            {
                return;
            }
            FromServer fsi = this.ServerItems[servicePort];

            fsi.TunnelClose();
        }
コード例 #3
0
        /// <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);
        }
コード例 #4
0
        protected override void OnDisconnected(CloseReason reason)
        {
            FromServer fsi = this.Monitor as FromServer;

            if (fsi == null)
            {
                return;
            }
            AgentServer.Instance.SendDisconnect(fsi.ServicePort, this.ConnectionID);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
            }
        }
コード例 #7
0
        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);
            }
        }