示例#1
0
 private async Task Run(CancellationToken cancellationToken)
 {
     _service                   = Service.Instance.GetServer();
     _service.OnError          += _service_OnError;
     _service.OnRecieved       += _service_OnRecieved;
     _service.OnStart          += _service_OnStart;
     _service.cancellationToken = cancellationToken;
     await _service.Start();
 }
示例#2
0
文件: Client.cs 项目: bvalente/dad
        static void Main()
        {
            TcpChannel channel = new TcpChannel();

            ChannelServices.RegisterChannel(channel, false);

            IServerChat server = (IServerChat)Activator.GetObject(
                typeof(IServerChat),
                "tcp://localhost:8086/ServerChat");

            try{
                Console.WriteLine(server.Ping());
            } catch (SocketException) {
                System.Console.WriteLine("socket error");
            }

            //end of file
            Console.ReadLine();
        }
示例#3
0
        public void Connect(Object sender, RoutedEventArgs e)
        {
            string port = portBox.Text;
            string nick = nickBox.Text;
            string url  = "tcp://localhost:" + port + "/ClientChat";

            //create connection
            TcpChannel channel = new TcpChannel(Int32.Parse(port));

            ChannelServices.RegisterChannel(channel, false);

            server = (IServerChat)Activator.GetObject(
                typeof(IServerChat),
                "tcp://localhost:8086/ServerChat");

            try{
                //Console.WriteLine(server.Ping());
                serverBlock.Text = server.Ping();
            } catch (SocketException e) {
                System.Console.WriteLine("socket error");
            }

            //marshal client chat

            client = new ClientChat(this);
            RemotingServices.Marshal(
                client,
                "ClientChat",
                typeof(ClientChat));

            //send info to server
            server.AddUser(nick, url); //catch exception?

            portBox.IsEnabled       = false;
            nickBox.IsEnabled       = false;
            connectButton.IsEnabled = false;
        }
示例#4
0
 public ChatHub(IServerChat _serverChat)
 {
     this._serverChat = _serverChat;
 }