Esempio n. 1
0
        private int RegisterClient(ISimulationService service, ISimulationCallback callback)
        {
            int        id;
            ClientInfo info;

            lock (clients)
            {
                id   = nextId++;
                info = new ClientInfo()
                {
                    ServiceInterface  = service,
                    CallbackInterface = callback,
                    UserProfile       = new UserProfile()
                    {
                        Id       = id,
                        Username = "******" + id
                    }
                };

                clients.Add(service, info);
            }

            // Send new User to the rest
            SendUserAdded(info.UserProfile);

            // Full Info Set to the new Client
            SendUserInit(info);

            return(id);
        }
Esempio n. 2
0
        /// <summary>
        /// Registers a new Client at the server Instance.
        /// </summary>
        /// <param name="service">Reference to the service</param>
        /// <param name="callback">Reference to the callback</param>
        /// <param name="server">output Parameter for the server Reference</param>
        /// <returns>New Id for this client.</returns>
        internal static int Register(ISimulationService service, ISimulationCallback callback, out SimulationServer server)
        {
            if (instance == null)
            {
                throw new Exception("Server is not running");
            }

            server = instance;
            return(instance.RegisterClient(service, callback));
        }
Esempio n. 3
0
        private int RegisterClient(ISimulationService service, ISimulationCallback callback)
        {
            int id;
            ClientInfo info;

            lock (clients)
            {
                id = nextId++;
                info = new ClientInfo()
                {
                    ServiceInterface = service,
                    CallbackInterface = callback,
                    UserProfile = new UserProfile()
                    {
                        Id = id,
                        Username = "******" + id
                    }
                };

                clients.Add(service, info);
            }

            // Send new User to the rest
            SendUserAdded(info.UserProfile);

            // Full Info Set to the new Client
            SendUserInit(info);

            return id;
        }
Esempio n. 4
0
        /// <summary>
        /// Registers a new Client at the server Instance.
        /// </summary>
        /// <param name="service">Reference to the service</param>
        /// <param name="callback">Reference to the callback</param>
        /// <param name="server">output Parameter for the server Reference</param>
        /// <returns>New Id for this client.</returns>
        internal static int Register(ISimulationService service, ISimulationCallback callback, out SimulationServer server)
        {
            if (instance == null)
                throw new Exception("Server is not running");

            server = instance;
            return instance.RegisterClient(service, callback);
        }
Esempio n. 5
0
 public SimulationService()
 {
     callback = OperationContext.Current.GetCallbackChannel<ISimulationCallback>();
     id = SimulationServer.Register(this, callback, out server);
 }
Esempio n. 6
0
 public SimulationService()
 {
     callback = OperationContext.Current.GetCallbackChannel <ISimulationCallback>();
     id       = SimulationServer.Register(this, callback, out server);
 }