Example #1
0
        //HANDLER DO FORM
        public bool Register(string nick, string port)
        {
            this.nick = nick;

            TcpChannel channel = new TcpChannel(Int32.Parse(port));

            ChannelServices.RegisterChannel(channel, true);

            ObjClient objClient = new ObjClient(formClient);

            RemotingServices.Marshal(objClient,
                                     "IChatClient",
                                     typeof(ObjClient));

            string serverUrl = "tcp://localhost:8086/IChatServer";

            serverObj = (ObjServer)Activator.GetObject(
                typeof(ObjServer), serverUrl);

            if (serverObj == null)
            {
                System.Console.WriteLine("Could not locate server");
                return(false);
            }

            string clientUrl = "tcp://localhost:" + port + "/IChatClient";

            serverObj.Register(nick, clientUrl);

            return(true);
        }
Example #2
0
        //HANDLER DO FORM
        public bool Register(string nick, string port)
        {
            this.nick = nick;

            TcpChannel channel = new TcpChannel(Int32.Parse(port));
            ChannelServices.RegisterChannel(channel, true);

            ObjClient objClient = new ObjClient(formClient);
            RemotingServices.Marshal(objClient,
                "IChatClient",
                typeof(ObjClient));

            string serverUrl = "tcp://localhost:8086/IChatServer";

            serverObj = (ObjServer)Activator.GetObject(
                typeof(ObjServer), serverUrl);

            if (serverObj == null) {
                System.Console.WriteLine("Could not locate server");
                return false;
            }

            string clientUrl = "tcp://localhost:" + port + "/IChatClient";
            serverObj.Register(nick, clientUrl);

            return true;
        }
Example #3
0
        public bool SendMsg(string nick, string message)
        {
            foreach (KeyValuePair <string, string> entry in dictClients)
            {
                if (nick == entry.Key)
                {
                    continue;
                }

                ObjClient obj = (ObjClient)Activator.GetObject(
                    typeof(ObjClient), entry.Value);

                if (obj == null)
                {
                    return(false);
                }

                System.Console.WriteLine("Sending to " + entry.Key + " : " + message);

                obj.RecvMsg(nick + "> " + message);
            }

            return(true);
        }