public AChannel GetChannel(NetChannelType channelType) { AChannel channel; this.channels.TryGetValue(channelType, out channel); return(channel); }
public bool BeginConnect(NetChannelType channel, string ip, int port, Action <bool, NetChannelType> callback = null) { NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return(false); } return(netChannel.BeginConnect(ip, port, callback)); }
public static void SendOOBPacket(NetChannelType type, NetAddress address, string format, params object[] others) { string message = "????" + string.Format(format, others); byte[] data = Encoding.UTF8.GetBytes(message); data[0] = 0xFF; data[1] = 0xFF; data[2] = 0xFF; data[3] = 0xFF; SendPacket(type, address, data); }
public bool RunFrameData(NetChannelType channel, int frameIndex) { NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return(false); } return(netChannel.RunFrameData(frameIndex)); }
public void DisConnect(NetChannelType channel) { NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return; } netChannel.DisConnect(); }
public bool IsChannelConnected(NetChannelType channelType) { AChannel channel = GetChannel(channelType); if (channel == null) { return(false); } return(true); }
public NetChannel(NetChannelType type, SocketClient socketClient) { m_eChannelType = type; m_queueRecvData = new Queue <NetRecvData>(); m_cSocketClient = socketClient; m_cSocketClient.OnDisConnect += OnDisConnect; m_dicServerMsg = new Dictionary <short, List <IServerMsg> >(); m_cMsgDispatcher = new EDynamicDispatcher(); m_cFrameData = new NetFrameData(); LoadNetMessageEvent(); }
private static void SendLoopbackPacket(NetChannelType type, byte[] packet) { if (type == NetChannelType.ClientToServer) { _serverLoopQueue.Enqueue(packet); } else if (type == NetChannelType.ServerToClient) { _clientLoopQueue.Enqueue(packet); } }
public void Close(NetChannelType channelType) { AChannel channel = this.GetChannel(channelType); if (channel == null || channel.Id == 0) { return; } this.channels.Remove(channelType); channel.Dispose(); }
public void RemoveMsgCallback(NetChannelType channel, short receiveOpcode, MsgCallback callback) { if (callback != null) { NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return; } netChannel.RemoveMsgCallback(receiveOpcode, callback); } }
public void AddMsgCallback(NetChannelType channel, short receiveOpcode, MsgCallback callback, bool once = false) { if (callback != null) { NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return; } netChannel.AddMsgCallback(receiveOpcode, callback, once); } }
//不监听回复消息 public void SendMsg(NetChannelType channel, short sendOpcode, object data) { NetSendData sendData; sendData.sendOpcode = sendOpcode; sendData.data = data; NetChannel netChannel = GetChannel(channel); if (netChannel == null) { return; } netChannel.SendMsg(sendData); }
private void OnConnect(bool succ, NetChannelType channel) { if (channel == NetChannelType.Game) { if (succ) { CLog.Log("连接战斗服务器成功"); FrameSyncSys.Instance.StartRun();//开始帧同步 this.OnExecuteDone(CmdExecuteState.Success); } else { CLog.LogError("连接战斗服务器失败"); this.OnExecuteDone(CmdExecuteState.Fail); } } }
public static void SendPacket(NetChannelType type, NetAddress address, byte[] packet) { if (address.Type == AddressType.Loopback) { SendLoopbackPacket(type, packet); } else { if (net_forceLatency.GetValue <int>() == 0) { SendPacketInternal(address, packet); } else { _sendQueue.Add(new NetPacket(address, packet)); } } }
public void CreateChannel(NetChannelType channel, NetChannelModeType channelMode) { var curChannel = GetChannel(channel); if (curChannel != null) { curChannel.DisConnect(); } curChannel = null; switch (channelMode) { case NetChannelModeType.Tcp: curChannel = new NetChannel(channel, new TCPSocketClient()); break; case NetChannelModeType.StandAlone: curChannel = new NetChannel(channel, new StandAloneSocketClient()); break; } m_arrChannel[(int)channel] = curChannel; }
public static byte[] GetLoopbackPacket(NetChannelType type) { Queue <byte[]> queue = null; if (type == NetChannelType.ClientToServer) { queue = _serverLoopQueue; } else if (type == NetChannelType.ServerToClient) { queue = _clientLoopQueue; } if (queue != null) { if (queue.Count > 0) { return(queue.Dequeue()); } } return(null); }
public NetChannel(NetChannelType type, NetAddress address) { ChannelType = type; Address = address; }
private void OnCallback(bool succ, NetChannelType channel) { CLog.Log("返回连接服务器结果:" + succ); }
/// <summary> /// Creates info from a net request /// </summary> /// <param name="fromReq"></param> public AssetRequestInfo(TransferRequestPacket fromReq, IClientAPI userInfo) { _origin = RequestOrigin.SRC_NET; _netSrc = (NetSourceType)fromReq.TransferInfo.SourceType; _netChannel = (NetChannelType)fromReq.TransferInfo.ChannelType; if (fromReq.TransferInfo.SourceType == 2) { //direct asset request _requestedId = new UUID(fromReq.TransferInfo.Params, 0); } else if (fromReq.TransferInfo.SourceType == 3) { //inventory asset request _requestedId = new UUID(fromReq.TransferInfo.Params, 80); } else if (fromReq.TransferInfo.SourceType == 4) { //sim estate request //We have to just send the covenent in this case, // I've looked through the params, and the UUID // of the covenent isn't in there (Matt Beardmore) _requestedId = userInfo.Scene.RegionInfo.RegionSettings.Covenant; } _transferId = fromReq.TransferInfo.TransferID; _params = fromReq.TransferInfo.Params; }
protected NetChannel GetChannel(NetChannelType type) { return(m_arrChannel[(int)type]); }
//监听回复消息 public void SendMsg(NetChannelType channel, short sendOpcode, short receiveOpcode, object data, MsgCallback callback) { AddMsgCallback(channel, receiveOpcode, callback, true); SendMsg(channel, sendOpcode, data); }
public void Connect(NetChannelType channelType, string host, int port) { AChannel channel = Share.Scene.GetComponent <NetworkComponent>().ConnectChannel(host, port); this.channels[channelType] = channel; }