コード例 #1
0
 protected void OnClientDisConnect(ANetChannel channel)
 {
     if (Channels.TryRemove(channel.Id, out ANetChannel value))
     {
         if (this.ProtocalType == ProtocalType.Wcp)
         {
             var wchannel = channel as WcpChannel;
             Log.Debug($"{this.ProtocalType}与服务端:{wchannel.HttpPrefixed}连接断开.", LoggerBllType.Network);
         }
         else
         {
             var loacalPort = channel.LocalEndPoint == null ? 0 : channel.LocalEndPoint.Port;
             Log.Debug($"{this.ProtocalType}端口:{loacalPort}与服务端:{channel.RemoteEndPoint}连接断开.", LoggerBllType.Network);
         }
         OnClientDisconnected?.Invoke(value);
     }
 }
コード例 #2
0
 protected void OnAccept(ANetChannel channel)
 {
     if (this.ProtocalType == ProtocalType.Wcp)
     {
         var wchannel = channel as WcpChannel;
         Log.Debug($"{this.ProtocalType}监听Prefied:{wchannel.HttpPrefixed}接受客户端:{channel.RemoteEndPoint}连接成功.", LoggerBllType.Network);
     }
     else
     {
         var loacalPort = channel.LocalEndPoint == null ? 0 : channel.LocalEndPoint.Port;
         Log.Debug($"{this.ProtocalType}监听端口:{loacalPort}接受客户端:{channel.RemoteEndPoint}连接成功.", LoggerBllType.Network);
     }
     channel.Connected = true;
     AddChannel(channel);
     channel.OnDisconnected = OnServerDisConnect;
     channel.OnReceive      = (p) => { channel.Network.Dispatching(p); };
     OnServerConnected?.Invoke(channel);
 }
コード例 #3
0
        protected void OnConnect(ANetChannel channel)
        {
            if (this.ProtocalType == ProtocalType.Wcp)
            {
                var wchannel = channel as WcpChannel;
                Log.Debug($"{this.ProtocalType}连接服务端:{wchannel.HttpPrefixed}成功.", LoggerBllType.Network);
            }
            else
            {
                var loacalPort = channel.LocalEndPoint == null ? 0 : channel.LocalEndPoint.Port;
                Log.Debug($"{this.ProtocalType}端口:{loacalPort}连接服务端:{channel.RemoteEndPoint}成功.", LoggerBllType.Network);
            }

            channel.Connected = true;
            this.AddChannel(channel);
            channel.OnDisconnected = OnClientDisConnect;
            channel.OnReceive      = (p) => { channel.Network.Dispatching(p); };
            this.OnClientConnected?.Invoke(channel);
        }
コード例 #4
0
ファイル: WcpService.cs プロジェクト: zjccwboy/GameProject
 private void OnAcceptComplete(ANetChannel channel)
 {
     OnAccept(channel);
     channel.StartRecv();
 }
コード例 #5
0
 public Network(ANetChannel channel)
 {
     this.Channel = channel;
     this.Session = channel.Session;
 }
コード例 #6
0
 internal void Subscribe(ANetChannel channel, Action <Packet> notificationAction, ushort netCommand)
 {
     channel.Subscribe(notificationAction, netCommand);
 }
コード例 #7
0
 internal void Subscribe <TRequest>(ANetChannel channel, TRequest data, Action <Packet> notificationAction, ushort netCommand)
 {
     channel.Subscribe(data, notificationAction, netCommand);
 }
コード例 #8
0
 internal void Send(ANetChannel channel, ushort netCommand, int rpcId)
 {
     channel.Send(netCommand, rpcId);
 }
コード例 #9
0
 internal void Send(ANetChannel channel, object data, ushort netCommand, int rpcId, Type type)
 {
     channel.Send(data, netCommand, rpcId, type);
 }
コード例 #10
0
 internal void Send <TSender>(ANetChannel channel, TSender data, ushort netCommand, int rpcId)
 {
     channel.Send(data, netCommand, rpcId);
 }
コード例 #11
0
 protected void AddChannel(ANetChannel channel)
 {
     Channels.TryAdd(channel.Id, channel);
 }