Exemplo n.º 1
0
 public bool Connect (INetworkView net, string ipAddr, int port) {
     client = new JacoChatClient.JacoChatClient ();
     try {
         client.Connect (ipAddr, port);
     } catch {
         return false;
     }
     network = net;
     client.MessageRecieved += Client_MessageRecieved;
     net.Connected (this);
     return true;
 }
Exemplo n.º 2
0
 public bool Connect(INetworkView net, string ipAddr, int port)
 {
     client = new JacoChatClient.JacoChatClient();
     try {
         client.Connect(ipAddr, port);
     } catch {
         return(false);
     }
     network = net;
     client.MessageRecieved += Client_MessageRecieved;
     net.Connected(this);
     return(true);
 }
Exemplo n.º 3
0
        public bool Connect(string server, int port, bool ssl = false, int timeout = 1800)
        {
            client.BeginConnect(server, port, result => {
                connectDone.Set();
            }, this);

            connectDone.WaitOne(1800, false);

            if (!client.Connected)
            {
                return(false);
            }

            Stream baseStream = client.GetStream();

            if (ssl)
            {
                baseStream = new SslStream(baseStream, false,
                                           new RemoteCertificateValidationCallback((sender, certificate, chain, sslPolicyErrors) => true),
                                           null);
                ((SslStream)baseStream).AuthenticateAsClient(server);
            }

            streamWriter = new StreamWriter(baseStream);
            streamReader = new StreamReader(baseStream);

            ConnectEventArgs args = new ConnectEventArgs();

            networkView.Connected(this);
            Thread.Sleep(100);
            OnConnectionMade(args);

            Nickname = args.Nickname ?? BirchSettings.Instance.Nickname;
            Hostname = args.Hostname ?? "BirchClient";
            Username = args.Realname ?? BirchSettings.Instance.Username;

            SendRaw("USER {0} {1} {2} :{3}", Nickname, Hostname, Hostname, Username);
            SendRaw("NICK {0}", Nickname);
            EnterMessageLoop();

            return(true);
        }
Exemplo n.º 4
0
 public bool Connect (INetworkView net, string ipAddr, int port) {
     client = new JacoChatClient.JacoChatClient ();
     try {
         client.Connect (ipAddr, port);
     } catch {
         return false;
     }
     network = net;
     client.PrivmsgRecieved += Client_PrivmsgRecieved;
     client.NamesRecieved += Client_NamesRecieved;
     client.NickRecieved += Client_NickRecieved;
     client.JoinRecieved += Client_JoinRecieved;
     client.PartRecieved += Client_PartRecieved;
     client.ErrorRecieved += Client_ErrorRecieved;
     client.UnknownRecieved += Client_UnknownRecieved;
     client.TopicRecieved += Client_TopicRecieved;
     client.QuitRecieved += Client_QuitRecieved;
     client.WhoisRecieved += Client_WhoisRecieved;
     net.Connected (this);
     return true;
 }