public static void Init <T>() where T : INetworkInterface, new ()
    {
        //提前加载网络事件派发器,避免异步冲突
        InputManager.LoadDispatcher <InputNetworkConnectStatusEvent>();
        InputManager.LoadDispatcher <InputNetworkMessageEvent>();

        s_network = new T();
        s_network.Init();
        s_network.m_messageCallBack       = ReceviceMeaasge;
        s_network.m_ConnectStatusCallback = ConnectStatusChange;

        ApplicationManager.s_OnApplicationUpdate += Update;
        ApplicationManager.s_OnApplicationQuit   += DisConnect;
    }
Esempio n. 2
0
    private void NetInit()
    {
        s_network.m_socketService.m_byteCallBack          = s_network.SpiltMessage;
        s_network.m_socketService.m_connectStatusCallback = ConnectStatusChange;
        s_network.m_socketService.Init();

        s_network.Init();
        s_network.m_messageCallBack = ReceviceMeaasge;

        foreach (var item in plugins.Values)
        {
            item.SetNetwork(this);
        }
    }
Esempio n. 3
0
    private static void NetInit()
    {
        //提前加载网络事件派发器,避免异步冲突
        InputManager.LoadDispatcher <InputNetworkConnectStatusEvent>();
        InputManager.LoadDispatcher <InputNetworkMessageEvent>();
        s_network.m_socketService.m_byteCallBack          = s_network.SpiltMessage;
        s_network.m_socketService.m_connectStatusCallback = ConnectStatusChange;
        s_network.m_socketService.Init();

        s_network.Init();
        s_network.m_messageCallBack = ReceviceMeaasge;

        ApplicationManager.s_OnApplicationUpdate += Update;
        ApplicationManager.s_OnApplicationQuit   += DisConnect;
    }
    public static void Init(string networkInterfaceName)
    {
        //提前加载网络事件派发器,避免异步冲突
        InputManager.LoadDispatcher <InputNetworkConnectStatusEvent>();
        InputManager.LoadDispatcher <InputNetworkMessageEvent>();

        Type type = Type.GetType(networkInterfaceName);

        s_network = Activator.CreateInstance(type) as INetworkInterface;
        s_network.Init();
        s_network.m_messageCallBack       = ReceviceMeaasge;
        s_network.m_ConnectStatusCallback = ConnectStatusChange;

        ApplicationManager.s_OnApplicationUpdate += Update;
        ApplicationManager.s_OnApplicationQuit   += DisConnect;
    }
    /// <summary>
    /// 网络初始化
    /// </summary>
    /// <typeparam name="TProtocol">协议处理类</typeparam>
    /// <typeparam name="TSocket">Socket类</typeparam>
    /// <param name="protocolType">通讯协议</param>
    public static void Init <TProtocol, TSocket>(ProtocolType protocolType = ProtocolType.Tcp) where TProtocol : INetworkInterface, new () where TSocket : SocketBase, new()
    {
        //提前加载网络事件派发器,避免异步冲突
        InputManager.LoadDispatcher <InputNetworkConnectStatusEvent>();
        InputManager.LoadDispatcher <InputNetworkMessageEvent>();

        s_network = new TProtocol();
        s_network.m_socketService = new TSocket();
        s_network.m_socketService.m_byteCallBack          = s_network.SpiltMessage;
        s_network.m_socketService.m_connectStatusCallback = ConnectStatusChange;
        s_network.m_socketService.m_protocolType          = protocolType;
        s_network.m_socketService.Init();

        s_network.Init();
        s_network.m_messageCallBack = ReceviceMeaasge;

        ApplicationManager.s_OnApplicationUpdate += Update;
        ApplicationManager.s_OnApplicationQuit   += DisConnect;
    }
Esempio n. 6
0
    public static void Init(string networkInterfaceName, string socketName)
    {
        //提前加载网络事件派发器,避免异步冲突
        //InputManager.LoadDispatcher<InputNetworkConnectStatusEvent>();
        //InputManager.LoadDispatcher<InputNetworkMessageEvent>();

        Type type = Type.GetType(networkInterfaceName);

        s_network = Activator.CreateInstance(type) as INetworkInterface;

        Type socketType = Type.GetType(networkInterfaceName);

        s_network.m_socketService = Activator.CreateInstance(socketType) as SocketBase;
        s_network.m_socketService.m_byteCallBack          = s_network.SpiltMessage;
        s_network.m_socketService.m_connectStatusCallback = ConnectStatusChange;
        s_network.m_socketService.Init();

        s_network.Init();
        s_network.m_messageCallBack = ReceviceMeaasge;

        //ApplicationManager.s_OnApplicationUpdate += Update;
        //ApplicationManager.s_OnApplicationQuit += DisConnect;
    }