Esempio n. 1
0
        // Connect to a remote asynchronously.
        public void ConnectInBackground(DarkRiftClient.ConnectCompleteHandler callback = null)
        {
            _darkRiftClient.ConnectInBackground(_ip, Port, IpVersion,
                                                delegate(Exception e)
            {
                if (callback != null)
                {
                    if (_invokeFromDispatcher)
                    {
                        _dispatcher.InvokeAsync(() => callback(e));
                    }
                    else
                    {
                        callback.Invoke(e);
                    }
                }

                _dispatcher.InvokeAsync(
                    delegate
                {
                    if (Connected)
                    {
                        Debug.Log("Connected to " + _ip + " on port " + Port + " using " + IpVersion + ".");
                    }
                    else
                    {
                        Debug.Log("Connection failed to " + _ip + " on port " + Port + " using " + IpVersion +
                                  ".");
                    }
                }
                    );
            }
                                                );
        }
Esempio n. 2
0
 public bool StartClient(string address, int port)
 {
     if (IsClientStarted)
     {
         return(false);
     }
     clientEventQueue.Clear();
     Client = new DarkRiftClient();
     Client.Disconnected    += Client_Disconnected;
     Client.MessageReceived += Client_MessageReceived;
     if (address.Equals("localhost"))
     {
         address = "127.0.0.1";
     }
     Client.ConnectInBackground(IPAddress.Parse(address), port, IPVersion.IPv4, (exception) =>
     {
         if (exception != null)
         {
             UnityEngine.Debug.LogException(exception);
             clientEventQueue.Enqueue(new TransportEventData()
             {
                 type        = ENetworkEvent.ErrorEvent,
                 socketError = SocketError.ConnectionRefused,
             });
         }
         else
         {
             clientEventQueue.Enqueue(new TransportEventData()
             {
                 type = ENetworkEvent.ConnectEvent,
             });
         }
     });
     return(true);
 }
Esempio n. 3
0
        protected override void Loaded(LoadedEventArgs loadedArgs)
        {
            base.Loaded(loadedArgs);

            _game = PluginManager.GetPluginByType <GamePlugin>();

            WriteEvent("Connecting to " + MasterIpAddress + ":" + MasterPort, LogType.Info);
            _client.MessageReceived += OnMessageFromMaster;
            _client.ConnectInBackground(MasterIpAddress, MasterPort, IPVersion.IPv4, OnConnectedToMaster);

            ClientManager.ClientConnected += OnPlayerConnected;
        }
Esempio n. 4
0
        public SpawnerClient()
        {
            _freePorts = new Queue <int>();

            MasterIpAddress = IPAddress.Parse(Settings.Default.MasterIpAddress);
            MasterPort      = Convert.ToInt32(Settings.Default.MasterPort);

            SpawnerIpAddress = Settings.Default.SpawnerIpAddress;
            SpawnerStartPort = Settings.Default.SpawnerStartPort;
            MaxProcesses     = Settings.Default.MaxProcesses;
            ExecutablePath   = Settings.Default.ExecutablePath;
            Region           = Settings.Default.Region;
            AutoStartSpawner = Settings.Default.AutoStartSpawner;
            CreateRoomWindow = Settings.Default.CreateRoomWindow;
            ConfigPath       = Settings.Default.ConfigPath;
            UseShellExecute  = Settings.Default.UseShellExecute;
            UseMono          = Settings.Default.UseMono;



            _client = new DarkRiftClient();
            _client.ConnectInBackground(MasterIpAddress, MasterPort, IPVersion.IPv4, OnConnectedToMaster);
        }