Exemple #1
0
        public void BroadcastSim(string sender, string format, params string[] args)
        {
            try
            {
                OSChatMessage c = new OSChatMessage();
                c.From       = sender;
                c.Message    = String.Format(format, args);
                c.Type       = ChatTypeEnum.Region; // ChatTypeEnum.Say;
                c.Position   = CenterOfRegion;
                c.Sender     = null;
                c.SenderUUID = UUID.Zero;

                ChannelState.OSChat(this, c, true);
            }
            catch (Exception ex) // IRC gate should not crash Sim
            {
                m_log.ErrorFormat("[IRC-Connector-{0}]: BroadcastSim Exception Trap: {1}\n{2}", idn, ex.Message, ex.StackTrace);
            }
        }
Exemple #2
0
        public void ListenerRun()
        {
            string inputLine;
            int    resetk = m_resetk;

            try
            {
                while (m_enabled && m_connected)
                {
                    if ((inputLine = m_reader.ReadLine()) == null)
                    {
                        throw new Exception("Listener input socket closed");
                    }

                    // m_log.Info("[IRCConnector]: " + inputLine);

                    if (inputLine.Contains("PRIVMSG"))
                    {
                        Dictionary <string, string> data = ExtractMsg(inputLine);

                        // Any chat ???
                        if (data != null)
                        {
                            OSChatMessage c = new OSChatMessage();
                            c.Message    = data["msg"];
                            c.Type       = ChatTypeEnum.Region;
                            c.Position   = CenterOfRegion;
                            c.From       = data["nick"];
                            c.Sender     = null;
                            c.SenderUUID = UUID.Zero;

                            // Is message "\001ACTION foo bar\001"?
                            // Then change to: "/me foo bar"

                            if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
                            {
                                c.Message = String.Format("/me {0}", c.Message.Substring(8, c.Message.Length - 9));
                            }

                            ChannelState.OSChat(this, c, false);
                        }
                    }
                    else
                    {
                        ProcessIRCCommand(inputLine);
                    }
                }
            }
            catch (Exception /*e*/)
            {
                // m_log.ErrorFormat("[IRC-Connector-{0}]: ListenerRun exception trap: {1}", idn, e.Message);
                // m_log.Debug(e);
            }

            // This is potentially circular, but harmless if so.
            // The connection is marked as not connected the first time
            // through reconnect.

            if (m_enabled && (m_resetk == resetk))
            {
                Reconnect();
            }
        }