Example #1
0
        public override bool Open(NetworkClientConfig config)
        {
            if (!NetworkHelper.UdpClient(config.LocalEndPoint, out var socket))
            {
                return(false);
            }

            Config     = config;
            UdpClient  = socket;
            Connection = Kernel.Get <BaseNetworkConnection>();
            Connection.Init(UdpClient, Config.ConnectionConfig);

            TokenManager.Init(UdpClient);
            TokenCache.Init(UdpClient, TokenManager);
            return(true);
        }
Example #2
0
        public override bool Open(NetworkServerConfig config)
        {
            if (!NetworkHelper.UdpClient(config.BindEndPoint, out var socket))
            {
                return(false);
            }

            UdpClient = socket;
            TokenManager.Init(UdpClient);
            TokenCache.Init(UdpClient, TokenManager);

            Config      = CheckConfig(config);
            Connections = new BaseNetworkConnection[Config.MaxClients];

            for (var i = 0; i < Connections.Count; i++)
            {
                Connections[i] = Kernel.Get <BaseNetworkConnection>();
                Connections[i].Init(UdpClient, Config.ConnectionConfig);
            }

            return(true);
        }