Ejemplo n.º 1
0
        private void Button_Click(object sender, RoutedEventArgs e)
        {

            String nick;
            String serverAddr;
            String serverPort;
            nick = TextboxNick.Text.ToString();
            serverAddr = TextBoxAddr.Text.ToString();
            serverPort = TextBoxPort.Text.ToString();

            if (nick.Length > 0)
            {
                if(serverAddr.Length>7)
                {
                    if (serverPort.Length > 0)
                    {
                        User user = new User(nick);
                        MenuGlowne menu = new MenuGlowne(user, serverAddr,serverPort);
                        this.Close();
                        menu.ShowDialog();
                    } else { MessageBox.Show("Wpisz numer portu!"); }
                }else { MessageBox.Show("Wpisz poprawny adres IP!"); }
            }
            else { MessageBox.Show("Nie podano nicku!"); }
        }
Ejemplo n.º 2
0
        public List<Room> UserInsideRooms = new List<Room>(); //lista pokoi w których jest użytkownik (i mają dochodzić do niego wiadomości od innych)

        public MenuGlowne(User userfrommain, String serverAddrString, String serverPort)
        {
            InitializeComponent();
            this.thisWindow = this;
            this.user = userfrommain;
            this.serverAddrString = serverAddrString;
            this.serverPort = serverPort;
            serverAddr = IPAddress.Parse(serverAddrString);
                      
            Channels.Dispatcher.BeginInvoke(new Action(delegate()
            {
                Channels.ItemsSource = null;
                Channels.ItemsSource = Rooms;
            }));
            ActualRoom = Main;
            ActualRoom.IsInside = IRC.Room.inside.TAK;
            Rooms.Add(Main);
            setThreadedRoomName(Main.Name);
            UserInsideRooms.Add(Main);
            setThreadedChat(); //ustawiay chatbox na chat danego roomu

            //jeżeli klikniemy X (bez przycisku "wyjdź z serwera"
            AppDomain.CurrentDomain.ProcessExit += new EventHandler(OnProcessExit);

            ConnectwithIP();
       }
Ejemplo n.º 3
0
 public Message(User user, string text)
 {
     DateTime = DateTime.Now;
     User = user;
     Text = text;
 }
Ejemplo n.º 4
0
 public void Invite(User user)
 {
     _client.Invite(user.Nick, Name);
 }
Ejemplo n.º 5
0
 private void OnParted(User user)
 {
     EventHandler<User> handler = Parted;
     if (handler != null) handler(this, user);
 }
Ejemplo n.º 6
0
 private void OnJoined(User user)
 {
     if (Joined != null) Joined(this, user);
 }
Ejemplo n.º 7
0
        public void ProcessReply(object sender, Reply reply)
        {
            // todo maybe check parm[0] for "name" before continuing
            // parm 0 is always channel name on text and nickname on code?!?
            // not sure why we bother to test this!?!
            //if (reply.Params[0] != _client.Nickname)
                //return;

            // todo maybe handle text only in client and delgate codes to the domain classes
            switch (reply.Command)
            {
                case "JOIN" :
                    if (reply.Params.Count <= 0 || reply.Params[0] != Name)
                        OnJoined(new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!'))));
                    break;
                case "PRIVMSG" :
                    {
                        if (reply.Params.Count == 0 || reply.Params[0] != Name)
                            return;
                        var user = new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!')));
                        OnMessage(new Message(user, reply.Trailing));
                        break;
                    }
                case "QUIT" :
                    if (reply.Params.Count <= 0 || reply.Params[0] != Name)
                    {
                        var user = new User(_client, reply.Prefix.Substring(0, reply.Prefix.IndexOf('!')))
                        {
                            LeaveMessage = reply.Trailing
                        };
                        OnParted(user);
                    }
                    break;
            }

            int code;
            if (!int.TryParse(reply.Command, out code))
                return;

            switch ((ReplyCode) code)
            {
                case ReplyCode.RplTopic :
                    if (reply.Params[1] != Name)
                        return;
                    Topic = new Topic(reply.Trailing);
                    OnTopicChanged();
                    break;
                case ReplyCode.RplTopicSetBy:
                    if (reply.Params[1] != Name) // not this channel
                        return;
                            // 0 is client nickname
                    // todo may not use this
                    _client.Logger("Topic set by " + reply.Params[2]);
                    break;
                case ReplyCode.RplNameReply:
                    if(_names == null) _names = new NamesList();
                   foreach (var user in reply.Trailing.Split().Select(name => new User(_client, name)))
                       _names.Add(user);
                    break;
                case ReplyCode.RplEndOfNames:
                    OnNamesList(new NamesList(_names));
                    break;
                case ReplyCode.RplNoTopic:
                    Topic = new Topic();
                    break;
            }
        }
Ejemplo n.º 8
0
 public void Kick(User user)
 {
 }
Ejemplo n.º 9
0
 public void addUser(User addingUser)
 {
     users.Add(addingUser);
 }
Ejemplo n.º 10
0
 public static void User(this Client client, string user, User.Mode mode, string realname)
 {
     client.Send("USER " + user + " " + mode + " * :" + realname);
 }