예제 #1
0
        public override void ServerStart()
        {
            m_Server?.Dispose();

            ServerConfig config;

            if (!string.IsNullOrWhiteSpace(m_RsaXmlPath))
            {
                var xml = Resources.Load <TextAsset>(m_RsaXmlPath);
                config = ServerConfig.FromXML(xml.text, m_Port);
            }
            else
            {
                config = ServerConfig.Create(m_Port);
            }
            m_Server              = Connection.StartServer(config);
            m_Server.OnPeerEvent += (e) =>
            {
                switch (e.EventType)
                {
                case PeerEvent.Type.Add:
                    OnServerConnected?.Invoke(Mathf.Abs(e.Peer.ConnectionId));
                    break;

                case PeerEvent.Type.Remove:
                    OnServerDisconnected?.Invoke(Mathf.Abs(e.Peer.ConnectionId));
                    break;
                }
            };
        }
예제 #2
0
        void Awake()
        {
            Log.Init();
            Log.Level = Log.LogLevel.Trace;
            var config = ServerConfig.FromXML(Resources.Load <TextAsset>("private").text, Port);

            m_Server = Connection.StartServer(config);
            Connect();
        }
예제 #3
0
        public override SocketTasks StartServer()
        {
            ServerConfig config;

            if (!string.IsNullOrWhiteSpace(m_RsaXmlPath))
            {
                var xml = Resources.Load <TextAsset>(m_RsaXmlPath);
                config = ServerConfig.FromXML(xml.text, m_Port);
            }
            else
            {
                config = ServerConfig.Create(m_Port);
            }
            m_Server = Connection.StartServer(config);
            Setup(m_Server);
            return(SocketTask.Done.AsTasks());
        }