Пример #1
0
 /// <summary>
 /// Use <see cref="Initialize()"/> when initializing server
 /// </summary>
 /// <param name="mainChannel">The server main channel to use</param>
 public UNetServer(IServerChannel mainChannel)
 {
     _channelMgr = new ChannelManager();
     mainChannel.IsMainChannel = true;
     _channelMgr.UnsafeAddChannel(mainChannel);
     mainChannel.HostServer = this;
 }
Пример #2
0
 /// <summary>
 /// Initializes the server.
 /// Only use this if you haven't set a main channel with <see cref="UNetServer()"/>
 /// </summary>
 /// <param name="mainChannel">The server main channel to use</param>
 public void Initialize(IServerChannel mainChannel)
 {
     if (_channelMgr.GetChannel <IServerChannel>(ch => ch.IsMainChannel) != null)
     {
         return;
     }
     mainChannel.IsMainChannel = true;
     mainChannel.HostServer    = this;
     _channelMgr.UnsafeAddChannel(mainChannel);
     _channelMgr.GetChannel <IServerChannel>(mainChannel.Id).Start();
     _channelMgr.GetChannel <IServerChannel>(mainChannel.Id).OnPeerConnected +=
         (sender, e) => OnPeerConnected.Raise(sender, e);
 }