| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556 | using System.Collections.Concurrent;using Fort23.UTool;using NetCore;using NetCore.ContentParse;using NetCore.Protocol.MemoryPack;using NetServer.InternalServer;using NetServerCore.NetLink;namespace NetServer.ServerLogic;public class PublicLogicManager : LogicManagerBaisc<InternalMemoryRequst>{    private ConcurrentDictionary<long, IConnection> _concurrentDictionary =        new ConcurrentDictionary<long, IConnection>();    public override void Logic(object data, IConnection iConnection)    {        LogTool.Log("收到一个客户端请求");        byte[] databyte = data as byte[];        int index = 0;        byte[] serverType = new byte[4];        serverType[0] = databyte[index++];        serverType[1] = databyte[index++];        serverType[2] = databyte[index++];        serverType[3] = databyte[index++];        ServerType serverTypeEnum = (ServerType)BitConverter.ToInt32(serverType, 0);        byte[] TransparentData = new byte[databyte.Length - 4];        Array.Copy(databyte, 4, TransparentData, 0, TransparentData.Length);        InternalMemoryResponese internalMemoryResponese = new InternalMemoryResponese();        internalMemoryResponese.SendType = InternalSendType.Transparent;        internalMemoryResponese.ClinetConnectionId = iConnection.ConnectionId;        internalMemoryResponese.TransitData = TransparentData;        SendInternalServerManager.Instance.SendInternalServer(serverTypeEnum, internalMemoryResponese,            ResponeseCallBack);    }    private void ResponeseCallBack(InternalMemoryRequst internalMemoryRequst)    {        if (_concurrentDictionary.TryGetValue(internalMemoryRequst.ResponeseClinetConnectionId,                out IConnection iConnection))        {            iConnection.SendData(internalMemoryRequst.TransitData);        }    }    public override void AddConnection(IConnection iConnection)    {        _concurrentDictionary.TryAdd(iConnection.ConnectionId, iConnection);    }    public override void RemoveConnection(IConnection iConnection)    {        _concurrentDictionary.TryRemove(iConnection.ConnectionId, out _);    }}
 |