Exemple #1
0
 public RemoteClient(uint playerIndex, ILocalServer server, TcpClient client)
 {
     Ip          = ((IPEndPoint)client.Client.RemoteEndPoint).Address;
     PlayerIndex = playerIndex;
     Server      = server;
     this.client = client;
 }
Exemple #2
0
 public NtripClientContext(ILocalServer localServer, int mountPoint) : this(null)
 {
     _clientType           = NTRIP.ClientType.NTRIP_ServerLocal;
     _localServerDelegate  = localServer.GetBytesDelegate;
     _localDisposeDelegate = localServer.GetDisposeDelegate;
     _validUser            = true;
     _agent      = "NTRIP Local";
     _mountPoint = mountPoint;
 }
Exemple #3
0
        public RemoteClient(uint playerIndex, ILocalServer server, TcpClient client)
            : base(200)
        {
            Ip          = ((IPEndPoint)client.Client.RemoteEndPoint).Address;
            PlayerIndex = playerIndex;
            Server      = server;
            this.client = client;

            lastHeartbeatTimeProvider = () => LastHeartbeat;
            cancellationToken         = disconnectToken.Token;

            Run();
        }
Exemple #4
0
        public CasterService(CasterSettings settings)
        {
            _tcpListener    = new TcpListener(IPAddress.Any, settings.PortNumber);
            _casterPassword = settings.ServerPassword;

            int i = 0;

            foreach (NTRIPMountPoint mountPoint in settings.NTRIPMountPoints)
            {
                _mountPoints.Add(i, new MountPoint(mountPoint.Name, mountPoint.Format, mountPoint.Format, mountPoint.Carrier, mountPoint.NavSystem, mountPoint.Latitude, mountPoint.Longitude));
                i++;
            }

            foreach (NTRIPUser user in settings.NTRIPUsers)
            {
                _users.Add(new KeyValuePair <string, string>(user.UserName, user.UserPassword));
            }


            foreach (LocalServer localServer in settings.LocalServers)
            {
                if (!File.Exists(localServer.DLLPath))
                {
                    throw new FileNotFoundException("Couldn't find dll", localServer.DLLPath);
                }

                Assembly serverAssembly = Assembly.LoadFile(localServer.DLLPath);
                Type     serverType     = serverAssembly.GetType(localServer.ClassName);
                if (serverType == null)
                {
                    throw new NullReferenceException(String.Format("ClassName: {0} doesn't exist in {1}", localServer.ClassName, localServer.DLLPath));
                }
                else if (!CheckILocalServer(serverType))
                {
                    throw new Exception(String.Format("Class: {0} doesn't implement ILocalServer", serverType.Name));
                }

                ILocalServer serverInstance = null;

                foreach (ConstructorInfo constructor in serverType.GetConstructors())
                {
                    ParameterInfo[] parameter = constructor.GetParameters();
                    if (parameter.Length > 0)
                    {
                        if (parameter[0].ParameterType == typeof(String))
                        {
                            serverInstance = (ILocalServer)Activator.CreateInstance(serverType, localServer.ConstructorArguments);
                        }
                    }
                }

                //If type doesn't contain constructor with arguments create it using no parameters
                if (serverInstance == null)
                {
                    serverInstance = (ILocalServer)Activator.CreateInstance(serverType);
                }

                NtripClientContext piksi = new NtripClientContext(serverInstance, GetMountPoint(localServer.MountPoint));
                piksi.ClientType = ClientType.NTRIP_ServerLocal;
                _clients.Add(piksi);
            }
        }