Ejemplo n.º 1
0
 private void RaiseInputReceived(ConnectionArgs connectionArgs, string action)
 {
     if (this.UserCommandReceived != null)
     {
         this.UserCommandReceived(this, new CommandRecivedArgs(connectionArgs.Connection, action));
     }
 }
Ejemplo n.º 2
0
    // 连接成功时执行的函数
    void OnMainConnected(ConnectionArgs args, object state)
    {
        LCMsgSender.Singleton.IsTryingConn = false;
        //ClientNetProperty.Singleton.NotifyChanged((int)ClientNetProperty.ENPropertyChanged.enConnected, null);

        LCMsgSender.Singleton.SendCacheMsg();
    }
Ejemplo n.º 3
0
        private void CreateConnection()
        {
            //The hostname of the IRC server
            string server = "irc.darkmyst.org";

            //The bot's nick on IRC
            string nick = "ComBot";

            //Fire up the Ident server for those IRC networks
            //silly enough to use it.
            Identd.Start(nick);

            //A ConnectionArgs contains all the info we need to establish
            //our connection with the IRC server and register our bot.
            //This line uses the simplfied contructor and the default values.
            //With this constructor the Nick, Real Name, and User name are
            //all set to the same value. It will use the default port of 6667 and no server
            //password.
            ConnectionArgs cargs = new ConnectionArgs(nick, server);

            //When creating a Connection two additional protocols may be
            //enabled: CTCP and DCC. In this example we will disable them
            //both.
            connection = new Connection(cargs, false, false);

            //NOTE
            //We could have created multiple Connections to different IRC servers
            //and each would process messages simultaneously and independently.
            //There is no fixed limit on how many Connection can be opened at one time but
            //it is important to realize that each runs in its own Thread. Also,  separate event
            //handlers are required for each connection, i.e. the
            //same OnRegistered() handler cannot be used for different connection
            //instances.
        }
Ejemplo n.º 4
0
    // 连接成功时执行的函数
    void OnMainConnected(ConnectionArgs args, object state)
    {
        MessageTransfer.Singleton.IsTryingConn = false;
        ClientNetProperty.Singleton.NotifyChanged((int)ClientNetProperty.ENPropertyChanged.enConnected, null);

        MessageTransfer.Singleton.SendCacheCachedMessage();
    }
Ejemplo n.º 5
0
 void Instance_Connected(object sender, ConnectionArgs e)
 {
     if (e.Success)
     {
         if (e.IsSource)
         {
             this.SourceTFS     = TfsShared.Instance.SourceTFS.Name;
             this.SourceProject = TfsShared.Instance.SourceProject.Name;
             this.SourceWorking = false;
         }
         else
         {
             this.TargetTFS     = TfsShared.Instance.TargetTFS.Name;
             this.TargetProject = TfsShared.Instance.TargetProject.Name;
             this.TargetWorking = false;
             CanSetBypassRules  = false;
         }
     }
     else
     {
         if (e.IsSource)
         {
             this.SourceTFS     = this.SourceProject = string.Empty;
             this.SourceWorking = false;
         }
         else
         {
             this.TargetTFS     = this.TargetProject = string.Empty;
             this.TargetWorking = false;
             CanSetBypassRules  = true;
         }
         Working = false;
     }
 }
Ejemplo n.º 6
0
        public void Setup()
        {
            var args     = new ConnectionArgs("test", "irc.fake.com", false);
            var connMock = A.Fake <Connection>(x => x.WithArgumentsForConstructor(() => new Connection(args, false, false)));

            _server = new Server(connMock);
        }
Ejemplo n.º 7
0
 public void SetUp()
 {
     ConnectionArgs args = new ConnectionArgs("deltabot","irc.sventech.com");
     connection = new Connection( args );
     listener = new CtcpListener( connection);
     RegisterListeners();
     AssignLines();
 }
Ejemplo n.º 8
0
 public void SetUp()
 {
     ConnectionArgs args = new ConnectionArgs("deltabot","irc.sventech.com");
     buffer = new MemoryStream();
     connection = new Connection( args );
     connection.writer = new StreamWriter( buffer );
     connection.writer.AutoFlush = true;
 }
Ejemplo n.º 9
0
        /// <summary>
        /// Get the connection args that have been specified by the configuration information
        /// </summary>
        /// <returns>The relevant connection arguments</returns>
        private ConnectionArgs GetConnArgs()
        {
            var cargs = new ConnectionArgs(_botUsername, IrcHost)
            {
                Nick = _botUsername, RealName = _botUsername, UserName = _botUsername, ServerPassword = _botPassword
            };

            return(cargs);
        }
Ejemplo n.º 10
0
        private void StartLink()
        {
            this.LoadSettings();
            try
            {
                if (this.IRC != null)
                {
                    this.IRC.Disconnect("Restarting...");
                    this._IRC = null;
                }
            }
            catch { }

            ConnectionArgs cargs = new ConnectionArgs(this.Nickname, this.Server);

            cargs.Port     = this.Port;
            cargs.RealName = "VhaBot/" + BotShell.VERSION;

            if (this.ServerPassword != null && this.ServerPassword != string.Empty)
            {
                cargs.ServerPassword = this.ServerPassword;
            }
            this._IRC = new Connection(cargs, false, false);
            this.IRC.Listener.OnRegistered   += new RegisteredEventHandler(Listener_OnRegistered);
            this.IRC.Listener.OnPublic       += new PublicMessageEventHandler(Listener_OnPublic);
            this.IRC.Listener.OnAdmin        += new AdminEventHandler(Listener_OnAdmin);
            this.IRC.Listener.OnError        += new ErrorMessageEventHandler(Listener_OnError);
            this.IRC.Listener.OnJoin         += new JoinEventHandler(Listener_OnJoin);
            this.IRC.Listener.OnPart         += new PartEventHandler(Listener_OnPart);
            this.IRC.Listener.OnKick         += new KickEventHandler(Listener_OnKick);
            this.IRC.Listener.OnQuit         += new QuitEventHandler(Listener_OnQuit);
            this.IRC.Listener.OnAction       += new ActionEventHandler(Listener_OnAction);
            this.IRC.Listener.OnDisconnected += new DisconnectedEventHandler(Listener_OnDisconnected);
            this.IRC.Listener.OnTopicChanged += new TopicEventHandler(Listener_OnTopicChanged);
            this.IRC.Listener.OnNick         += new NickEventHandler(Listener_OnNick);
            this.IRC.Listener.OnPrivate      += new PrivateMessageEventHandler(Listener_OnPrivate);
            this.IRC.HandleNickTaken          = true;
            this.IRC.EnableCtcp = false;
            this.IRC.EnableDcc  = false;

            try
            {
                this.Closing   = false;
                this.Connected = false;
                this.ReconnectTimer.Enabled = false;
                this.QueueTimer.Enabled     = true;
                this.Output("Connecting...");
                this.IRC.Connect();
            }
            catch
            {
                this.ReconnectTimer.Enabled = true;
                this.Output("Unable to connect");
                this.Output("Retrying in " + this.ConnectDelay + " seconds");
            }
        }
Ejemplo n.º 11
0
        public ForgeBot(string channel, string opchannel, string nick, string server)
        {
            this.channel = channel.Trim(); this.opchannel = opchannel.Trim(); this.nick = nick.Replace(" ", ""); this.server = server;
            ConnectionArgs con = new ConnectionArgs(nick, server);

            con.Port   = Server.ircPort;
            connection = new Connection(con, false, false);
            banCmd     = new List <string>();
            if (Server.irc)
            {
                // Regster events for outgoing
                Player.PlayerChat       += new Player.OnPlayerChat(Player_PlayerChat);
                Player.PlayerConnect    += new Player.OnPlayerConnect(Player_PlayerConnect);
                Player.PlayerDisconnect += new Player.OnPlayerDisconnect(Player_PlayerDisconnect);

                // Regster events for incoming
                connection.Listener.OnNick         += new NickEventHandler(Listener_OnNick);
                connection.Listener.OnRegistered   += new RegisteredEventHandler(Listener_OnRegistered);
                connection.Listener.OnPublic       += new PublicMessageEventHandler(Listener_OnPublic);
                connection.Listener.OnPrivate      += new PrivateMessageEventHandler(Listener_OnPrivate);
                connection.Listener.OnError        += new ErrorMessageEventHandler(Listener_OnError);
                connection.Listener.OnQuit         += new QuitEventHandler(Listener_OnQuit);
                connection.Listener.OnJoin         += new JoinEventHandler(Listener_OnJoin);
                connection.Listener.OnPart         += new PartEventHandler(Listener_OnPart);
                connection.Listener.OnDisconnected += new DisconnectedEventHandler(Listener_OnDisconnected);

                // Load banned commands list
                if (File.Exists("text/ircbancmd.txt")) // Backwards compatibility
                {
                    using (StreamWriter sw = File.CreateText("text/irccmdblacklist.txt"))
                    {
                        sw.WriteLine("#Here you can put commands that cannot be used from the IRC bot.");
                        sw.WriteLine("#Lines starting with \"#\" are ignored.");
                        foreach (string line in File.ReadAllLines("text/ircbancmd.txt"))
                        {
                            sw.WriteLine(line);
                        }
                    }
                    File.Delete("text/ircbancmd.txt");
                }
                else
                {
                    if (!File.Exists("text/irccmdblacklist.txt"))
                    {
                        File.WriteAllLines("text/irccmdblacklist.txt", new String[] { "#Here you can put commands that cannot be used from the IRC bot.", "#Lines starting with \"#\" are ignored." });
                    }
                    foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt"))
                    {
                        if (line[0] != '#')
                        {
                            banCmd.Add(line);
                        }
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public Server Create(ConnectionArgs args)
        {
            var newServer = new Server(args);

            ServerList.Add(newServer);

            ServerAdded.Fire(this, new ServerEventArgs(newServer));

            return(newServer);
        }
Ejemplo n.º 13
0
        void UpdateState()
        {
            channel   = Server.ircChannel.Trim();
            opchannel = Server.ircOpChannel.Trim();
            nick      = Server.ircNick.Replace(" ", "");
            server    = Server.ircServer;

            args                = new ConnectionArgs(nick, server);
            args.Port           = Server.ircPort;
            args.ServerPassword = Server.ircIdentify && Server.ircPassword != "" ? Server.ircPassword : "******";
        }
        /// <summary>
        /// Handles the ConnectionFailed event of the Tester control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.Windows.RoutedEventArgs"/> instance containing the event data.</param>
        /// <exception cref="NotImplementedException"></exception>
        private async static void Tester_ConnectionFailed(object sender, System.Windows.RoutedEventArgs e)
        {
            Oracle_Tester      tester      = sender as Oracle_Tester;
            IOracleUIConnector uiConnector = tester.Sender as IOracleUIConnector;
            ConnectionArgs     args        = e as ConnectionArgs;
            String             msg         = args.Error;

            App.Riviera.Log.AppendEntry(msg, Protocol.Error, "Tester_ConnectionTest", "IOracleUIConnector");
            await CloseProgressDialog();

            await uiConnector.Sender.ShowDialog(TIT_ORACLE_CONN, msg);
        }
Ejemplo n.º 15
0
 void Instance_Connected(object sender, ConnectionArgs e)
 {
     if (e.Success && e.IsSource)
     {
         Working = true;
         StartMapping();
     }
     if (e.Success && !e.IsSource)
     {
         GetTargetProjectPlans();
     }
 }
Ejemplo n.º 16
0
        private void EventHandlerClientDisconnected(object sender, ConnectionArgs args)
        {
            lock (lockVar)
            {
                _connections.Remove(args.Connection);
            }

            if (this.UserDisconnected != null)
            {
                this.UserDisconnected(this, args);
            }
        }
Ejemplo n.º 17
0
        public void SetupConnection(ConnectionArgs args)
        {
            if (args.Nick == null)
            {
                throw new ArgumentNullException("ConnectionArgs.Nick");
            }

            Connection = new Connection(args, true, false)
            {
                HandleNickTaken = false
            };
        }
Ejemplo n.º 18
0
        public void ConnectionChanged(ConnectionArgs args)
        {
            if (args.State)
            {
                Logger.LogInformation($"Соединение с контроллером {args.Serial} " +
                                      $"установлено [{args.Endpoint}, {args.Protocol.ToString()}]. " +
                                      $"Версия ПО: {args.Revision}");
            }

            else
            {
                Logger.LogInformation($"Соединение с контроллером {args.Serial} разорвано");
            }
        }
Ejemplo n.º 19
0
        private void CreateConnection()
        {
            string server = "irc.ppy.sh";

            string nick     = Form1._Username.ToLower();
            string password = Form1._Password;

            ConnectionArgs cargs = new ConnectionArgs(nick, server)
            {
                Nick = nick, UserName = nick, ServerPassword = password
            };

            connection = new Connection(cargs, false, false);
        }
Ejemplo n.º 20
0
        void UpdateState()
        {
            channels   = Server.Config.IRCChannels.SplitComma();
            opchannels = Server.Config.IRCOpChannels.SplitComma();
            nick       = Server.Config.IRCNick.Replace(" ", "");
            server     = Server.Config.IRCServer;

            args          = new ConnectionArgs(nick, server);
            args.RealName = Server.SoftwareNameVersioned;
            args.Port     = Server.Config.IRCPort;
            bool usePass = Server.Config.IRCIdentify && Server.Config.IRCPassword.Length > 0;

            args.ServerPassword = usePass ? Server.Config.IRCPassword : "******";
        }
Ejemplo n.º 21
0
        public void Connect(string host, int port, string botnickname, string serverpassword)
        {
            //Create Identd server
            Identd.Start(botnickname);

            //Create connection args
            ircArgs                = new ConnectionArgs();
            ircArgs.Hostname       = host;
            ircArgs.Port           = port;
            ircArgs.ClientName     = "TWITCHCLIENT 3"; //yay, twitchclient 3 is out!
            ircArgs.Nick           = botnickname;
            ircArgs.RealName       = botnickname;
            ircArgs.UserName       = botnickname;
            ircArgs.ServerPassword = serverpassword;

            //Create ircConnection
            ircConnection = new Connection(ircArgs, false, false);

            //Setup our irc event handlers
            ircConnection.Listener.OnRegistered        += new RegisteredEventHandler(OnRegistered);
            ircConnection.Listener.OnPublic            += new PublicMessageEventHandler(OnPublic);
            ircConnection.Listener.OnPrivate           += new PrivateMessageEventHandler(OnPrivate);
            ircConnection.Listener.OnChannelModeChange += new ChannelModeChangeEventHandler(OnChannelModeChange);
            ircConnection.Listener.OnError             += new ErrorMessageEventHandler(OnError);
            ircConnection.Listener.OnDisconnected      += new DisconnectedEventHandler(OnDisconnected);
            ircConnection.Listener.OnAction            += new ActionEventHandler(OnAction);

            //Let's try connecting!
            try
            {
                Logger.Log.Write("Connecting to " + host + ":" + port + "...", ConsoleColor.DarkGray);
                ircConnection.Connect();
            }
            catch (Exception e)
            {
                Logger.Log.Write("Error connecting to network, exception: " + e.ToString(), ConsoleColor.Red);
                Identd.Stop();
                return;
            }

            //We made it!
            Logger.Log.Write("Connected to " + host, ConsoleColor.DarkGray);

            //Create our message queue poller
            messageQueue = new Queue <KeyValuePair <Channel, string> >();
            previousMessageTimestamps = new List <int>();
            messageThread             = new Thread(new ThreadStart(MessagePoller));
            messageThread.Start();
        }
Ejemplo n.º 22
0
        //---------------------------------------------------------------
        #endregion
        //---------------------------------------------------------------

        //---------------------------------------------------------------
        #region Methods
        //---------------------------------------------------------------
        private void Client_Received(ConnectionArgs args)
        {
            // Is there some partial headerdata left from the last packet?
            if (lastPacketDataFilled == 0)
            {
                // copy the new received data behind the partial header data and call HandleData.
                System.Buffer.BlockCopy(args.Connection.Data, 0, lastPacketData, lastPacketDataFilled, args.Connection.Filled);
                HandleData(lastPacketData, lastPacketDataFilled + args.Connection.Filled, 0);
            }
            else
            {
                // Otherwise it is a fresh new data packet, just pass over the received data.
                HandleData(args.Connection.Data, args.Connection.Filled, 0);
            }
        }
Ejemplo n.º 23
0
    // 连接失败时执行的函数
    void OnConnectFailed(ConnectionArgs args, ErrorArgs error, object state)
    {
        Debug.Log("OnConnectFailed !!!");
        LCMsgSender.Singleton.IsTryingConn = false;
        //ClientNetProperty.Singleton.NotifyChanged((int)ClientNetProperty.ENPropertyChanged.enConnectionFailed, error.ErrorType);

        // 如果没有得到SESSION才弹提示框
        //if (false == LCMsgSender.Singleton.GotSession)
        {
            UICommonMsgBoxCfg boxCfg = new UICommonMsgBoxCfg();
            boxCfg.mainTextPrefab = "UILostConnectionLabel";
            boxCfg.buttonNum      = 1;
            UICommonMsgBox.GetInstance().ShowMsgBox(OnConnectFailedButtonClick, null, boxCfg);
        }
    }
Ejemplo n.º 24
0
        private void AddUser(object sender, ConnectionArgs e)
        {
            if (sender is LoginFrm frm)
            {
                if (frm.Remembered)
                {
                    this.ip       = e.Client.IP;
                    this.userName = e.Client.SshClient.ConnectionInfo.Username;
                    this.pw       = frm.Password;
                }
            }
            AddSshUser(e.Client);
            //AddSftpUser(e.Client);

            btn_ssh.PerformClick();
        }
Ejemplo n.º 25
0
        public void Execute(Server context, string server, string port)
        {
            var args = new ConnectionArgs(Settings.Default.FirstNick, server, false);

            try
            {
                args.Port = int.Parse(port);
            }
            catch (Exception)
            {
                args.Port = 6667;
            }

            context.ChangeServer(args);
            context.Connect();
        }
Ejemplo n.º 26
0
        public void ChangeServer(ConnectionArgs args)
        {
            if (IsConnected)
            {
                Disconnect();
            }

            if (args.Nick == null)
            {
                args.Nick = Connection.ConnectionData.Nick;
            }

            UnhookEvents();
            SetupConnection(args);
            HookEvents();

            _serverChangeTime = DateTime.Now;
        }
Ejemplo n.º 27
0
 public void Execute(Server context, char[] switches, string server, string port)
 {
     foreach (char c in switches)
     {
         switch (c)
         {
         case 'n':     //New window and connect
             var args = new ConnectionArgs(Settings.Default.FirstNick, server, false);
             try
             {
                 args.Port = int.Parse(port);
             }
             catch (Exception)
             {
                 args.Port = 6667;
             }
             var svr = ServerManager.Instance.Create(args);
             svr.Connect();
             return;
         }
     }
 }
Ejemplo n.º 28
0
 protected void ClientOnConnection(object sender, ConnectionArgs e)
 {
     byte Type = e.Packet.ReadByte();
     switch (Type)
     {
         case 0xFC:
             GameState = MultiplayerGameState.Waiting;
             byte pType = e.Packet.ReadByte();
             Player = pType == 1 ? VelesConflict.Gameplay.PlayerType.Player1 : VelesConflict.Gameplay.PlayerType.Player2;
             break;
     }
 }
Ejemplo n.º 29
0
 static void _server_UserConnected(object sender, ConnectionArgs args)
 {
     Console.WriteLine("Połączenie : " + args.Connection.Ip.ToString());
 }
Ejemplo n.º 30
0
        void OnMasterConnection(object sender, ConnectionArgs e)
        {
            int Score = 0;
            IAsyncResult result = Provider.BeginGetData("Score", null, null);
            result.AsyncWaitHandle.WaitOne();
            Score = Provider.EndGetData<int>(result).Data;

            this.MessageBox.Text = "\n\n\n\n" + LocalizationData.LookingForGames;
            Packet m = new Packet();
            m.Write((byte)0);
            MasterClient.SendPacket(m);

            MessageBox.Locked = false;
        }
Ejemplo n.º 31
0
        public ForgeBot(string channel, string opchannel, string nick, string server)
        {
            this.channel = channel.Trim(); this.opchannel = opchannel.Trim(); this.nick = nick.Replace(" ", ""); this.server = server;
            banCmd       = new List <string>();
            banCmd.Add("resetbot");
            banCmd.Add("resetirc");
            banCmd.Add("oprules");
            banCmd.Add("irccontrollers");
            banCmd.Add("ircctrl");

            if (Server.irc)
            {
                ConnectionArgs con = new ConnectionArgs(nick, server);
                con.Port   = Server.ircPort;
                connection = new Connection(new UTF8Encoding(false), con);

                // Regster events for outgoing
                Player.PlayerChat       += Player_PlayerChat;
                Player.PlayerConnect    += Player_PlayerConnect;
                Player.PlayerDisconnect += Player_PlayerDisconnect;

                // Regster events for incoming
                connection.Listener.OnNick              += Listener_OnNick;
                connection.Listener.OnRegistered        += Listener_OnRegistered;
                connection.Listener.OnAction            += Listener_OnAction;
                connection.Listener.OnPublic            += Listener_OnPublic;
                connection.Listener.OnPrivate           += Listener_OnPrivate;
                connection.Listener.OnError             += Listener_OnError;
                connection.Listener.OnQuit              += Listener_OnQuit;
                connection.Listener.OnJoin              += Listener_OnJoin;
                connection.Listener.OnPart              += Listener_OnPart;
                connection.Listener.OnDisconnected      += Listener_OnDisconnected;
                connection.Listener.OnChannelModeChange += Listener_OnChannelModeChange;
                connection.Listener.OnNames             += Listener_OnNames;
                connection.Listener.OnKick              += Listener_OnKick;
                connection.Listener.OnKill              += Listener_OnKill;

                // Load banned commands list
                if (File.Exists("text/ircbancmd.txt"))   // Backwards compatibility
                {
                    using (StreamWriter sw = File.CreateText("text/irccmdblacklist.txt")) {
                        sw.WriteLine("#Here you can put commands that cannot be used from the IRC bot.");
                        sw.WriteLine("#Lines starting with \"#\" are ignored.");
                        foreach (string line in File.ReadAllLines("text/ircbancmd.txt"))
                        {
                            sw.WriteLine(line);
                        }
                    }
                    File.Delete("text/ircbancmd.txt");
                }
                else
                {
                    if (!File.Exists("text/irccmdblacklist.txt"))
                    {
                        File.WriteAllLines("text/irccmdblacklist.txt", new String[] { "#Here you can put commands that cannot be used from the IRC bot.", "#Lines starting with \"#\" are ignored." });
                    }
                    foreach (string line in File.ReadAllLines("text/irccmdblacklist.txt"))
                    {
                        if (line[0] != '#')
                        {
                            banCmd.Add(line);
                        }
                    }
                }
            }
        }
Ejemplo n.º 32
0
 public void SetupTest()
 {
     _connectionArgs = new ConnectionArgs();
     _connection     = new Connection(_connectionArgs, false, false);
 }
Ejemplo n.º 33
0
 private static void c_CreateConnectionCompleted(object sender, ConnectionArgs e)
 {
     if (!inited)
         c.SendMessage(new HelloMessage());
     inited = true;
 }
Ejemplo n.º 34
0
 public void ChangedStatus(object sender, ConnectionArgs args)
 {
     WriteLog("Index: " + args.Index + " Connected: " + args.Connected, args.Connected ? Color.Green : Color.Red);
 }
Ejemplo n.º 35
0
 void CrunchCore_OnCreateConnectionCompleted(object sender, ConnectionArgs e)
 {
     CrunchCore.SendMessage(new MatchRequestMessage());
 }
Ejemplo n.º 36
0
 public Server(ConnectionArgs settings)
 {
     SetupConnection(settings);
     HookEvents();
 }
Ejemplo n.º 37
0
 public void TestUser()
 {
     ConnectionArgs args = new ConnectionArgs();
     args.UserName = "******";
     args.ModeMask = "i";
     args.RealName = "realname";
     connection.Sender.User( args );
     Assertion.AssertEquals("USER username i * realname", BufferToString() );
 }