Exemple #1
0
        public ChatRoom(ISingleServer server, String username, String port)
        {
            InitializeComponent();
            this.server      = server;
            this.username    = username;
            this.address     = "tcp://localhost:" + port.ToString() + "/Message";
            this.Text        = " Chat - " + username;
            onlineUsers.View = View.List;
            groupChats.View  = View.List;
            activeUsers      = new Hashtable();
            chatTabs         = new Hashtable();
            groupChatsList   = new List <string>();
            UpdateOnlineUsers();
            UpdateGroupChats();
            evRepeater             = new AlterEventRepeater();
            evRepeater.alterEvent += new AlterDelegate(DoAlterations);
            server.alterEvent     += new AlterDelegate(evRepeater.Repeater);
            r = (RemMessage)RemotingServices.Connect(typeof(RemMessage), "tcp://localhost:" + port.ToString() + "/Message");    // connect to the registered my remote object here
            r.PutMyForm(this);
            groupChatActive = false;

            selectedGroup     = null;
            inviteToGroupChat = false;
        }
Exemple #2
0
        /* --- METHODS --- */

        /// <summary>
        /// Returns an instance of Client.
        /// </summary>

        public Client()
        {
            User = null;

            Log("Creating server proxy...");
            //   server = (IServer)RemotingServices.Connect(typeof(IServer), "tcp://localhost:9000/Server.rem");
            Log("Server proxy created.");


            // register the channel
            IDictionary props = new Hashtable();

            props["port"] = 0;  // let the system choose a free port
            BinaryServerFormatterSinkProvider serverProvider = new BinaryServerFormatterSinkProvider();

            serverProvider.TypeFilterLevel = System.Runtime.Serialization.Formatters.TypeFilterLevel.Full;
            BinaryClientFormatterSinkProvider clientProvider = new BinaryClientFormatterSinkProvider();
            TcpChannel chan = new TcpChannel(props, clientProvider, serverProvider);  // instantiate the channel

            ChannelServices.RegisterChannel(chan, false);                             // register the channel

            ChannelDataStore data = (ChannelDataStore)chan.ChannelData;

            this.port = new Uri(data.ChannelUris[0]).Port;                                                                       // get the port

            RemotingConfiguration.Configure("Client.exe.config", false);                                                         // register the server objects
            RemotingConfiguration.RegisterWellKnownServiceType(typeof(RemMessage), "Client.Rem", WellKnownObjectMode.Singleton); // register my remote object for service

            this.mainPage = new MainPage(this);
            RemMessage r = (RemMessage)RemotingServices.Connect(typeof(RemMessage), "tcp://localhost:" + port.ToString() + "/Client.Rem");    // connect to the registered my remote object here

            r.PutMyForm(this.mainPage);

            //r.PutMyForm(mainPage);
            server = (IServer)Activator.GetObject(typeof(IServer), "tcp://localhost:9000/Server.rem");
        }