예제 #1
0
        /// <summary>
        /// Implementation of <see cref="OnChatMessage"/> that recieves messages from all channels of all connected <see cref="ChatProviders"/>
        /// </summary>
        /// <param name="ChatProvider">The <see cref="IChatProvider"/> that heard the <paramref name="message"/></param>
        /// <param name="speaker">The user who wrote the <paramref name="message"/></param>
        /// <param name="channel">The channel the <paramref name="message"/> is from</param>
        /// <param name="message">The recieved message</param>
        /// <param name="isAdmin"><see langword="true"/> if <paramref name="speaker"/> is considered a chat admin, <see langword="false"/> otherwise</param>
        /// <param name="isAdminChannel"><see langword="true"/> if <paramref name="channel"/> is an admin channel, <see langword="false"/> otherwise</param>
        private void ChatProvider_OnChatMessage(IChatProvider ChatProvider, string speaker, string channel, string message, bool isAdmin, bool isAdminChannel)
        {
            var splits = message.Trim().Split(' ');

            if (splits.Length == 1 && splits[0] == "")
            {
                ChatProvider.SendMessageDirect("Hi!", channel);
                return;
            }

            var asList = new List <string>(splits);

            Command.OutputProcVar.Value   = (m) => ChatProvider.SendMessageDirect(m, channel);
            ChatCommand.CommandInfo.Value = new CommandInfo()
            {
                IsAdmin        = isAdmin,
                IsAdminChannel = isAdminChannel,
                Speaker        = speaker,
                Server         = this,
            };
            WriteInfo(String.Format("Chat Command from {0} ({2}): {1}", speaker, String.Join(" ", asList), channel), EventID.ChatCommand);
            if (ServerChatCommands == null)
            {
                LoadServerChatCommands();
            }
            new RootChatCommand(ServerChatCommands).DoRun(asList);
        }
예제 #2
0
 public MainHub(IAuthService authService, IChatService chatService,
                IChatProvider provider, IChatConnectionsStore connectionsStore)
 {
     _authService      = authService;
     _chatService      = chatService;
     _provider         = provider;
     _connectionsStore = connectionsStore;
 }
예제 #3
0
 public PrivateMessageActions(IHudControlProvider hudControlProvider,
                              IChatProvider chatProvider,
                              IChatTypeCalculator chatTypeCalculator)
 {
     _hudControlProvider = hudControlProvider;
     _chatProvider       = chatProvider;
     _chatTypeCalculator = chatTypeCalculator;
 }
예제 #4
0
 public DownloadButton(DataLink link, IChatProvider server)
 {
     InitializeComponent();
     _server = server;
     this.FileNameLable.Content = link.FileName;
     SetReadableSize(link.Length);
     _fileAdress = link.Adress;
     FileName    = link.FileName;
 }
예제 #5
0
        private async void Connect_btn_Click(object sender, RoutedEventArgs e)
        {
            if (this.UserNameBox.Text != String.Empty && (this.AdressBox.SelectedItem != null || this.AdressBox.Text != String.Empty))
            {
                _name = this.UserNameBox.Text;
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("Some fields are empty");
                return;
            }
            string local_machine = (this.AdressBox.SelectedItem != null)? this.AdressBox.SelectedItem.ToString(): this.AdressBox.Text;

            if (local_machine != null)
            {
                try
                {
                    this.ConnectionLabel.Content = String.Format("Connecting to {0}", local_machine);
                    InstanceContext context = new InstanceContext(this);
                    chat_service = new ChatProviderClient(context, "NetTcpBinding_IChatProvider", String.Format("net.tcp://{0}:8733/ChatProvider/", local_machine));

                    await chat_service.RegisterNewUserAsync(_name);

                    this.UserNameLabel.Content = _name + ":";

                    this.ConnectionLabel.Content = "Getting users list";

                    var users = await chat_service.GetUsersListAsync();

                    users.ForEach(user => this.UsersList.Items.Add(user));

                    this.ConnectionLabel.Content = String.Format("Connected to {0}", local_machine);
                }
                catch (EndpointNotFoundException)
                {
                    System.Windows.Forms.MessageBox.Show(string.Format("It seems that {0} doesn't host ChatServer", local_machine));
                    chat_service = null;
                    this.ConnectionLabel.Content = "Disconnected";
                }
                catch (FaultException <ExceptionType> fault)
                {
                    chat_service = null;
                    var error_type = fault.Detail;
                    if (error_type == ExceptionType.UserAlreadyRegisterd)
                    {
                        System.Windows.Forms.MessageBox.Show(String.Format("User with name {0} already registered.\nTry Another name", _name));
                    }
                    this.ConnectionLabel.Content = "Disconnected";
                }
                catch (Exception ex)
                {
                    System.Windows.Forms.MessageBox.Show(ex.Message);
                    chat_service = null;
                    this.ConnectionLabel.Content = "Disconnected";
                }
            }
        }
예제 #6
0
 private void ConnectButton_MouseClick(object sender, MouseEventArgs e)
 {
     if (networkListbox.SelectedItem != null)
     {
         NetworkInformation information = (NetworkInformation)networkListbox.SelectedItem;
         NetworkForm        networkForm = new NetworkForm(information.Name);
         networkForm.MdiParent = BirchMainForm.Instance;
         networkForm.Show();
         IChatProvider proto = information.DoConnect(networkForm);
         Close();
     }
 }
예제 #7
0
        protected override void Initiate(out LevelInfo info, out IChatProvider chatProvider)
        {
            info                 = new LevelInfo();
            chatProvider         = Client;
            _initiated           = true;
            Client.WorldReceiver = WorldReceiver;
            WorldReceiver?.UpdatePlayerPosition(new API.Utils.PlayerLocation(
                                                    new Vector3(Client.CurrentLocation.X, Client.CurrentLocation.Y, Client.CurrentLocation.Z),
                                                    Client.CurrentLocation.HeadYaw, Client.CurrentLocation.Yaw, Client.CurrentLocation.Pitch));

            _gameTickTimer = new System.Threading.Timer(GameTick, null, 50, 50);
        }
예제 #8
0
 public void Connected (IChatProvider provider) {
     chatProvider = provider;
     Invoke (new MethodInvoker (() => {
         statusControl = new ChatControl (chatProvider, null);
         statusControl.Dock = DockStyle.Fill;
         TabPage statusPage = new TabPage ();
         statusPage.Text = "Status";
         statusPage.Dock = DockStyle.Fill;
         statusPage.Controls.Add (statusControl);
         tabControl.TabPages.Add (statusPage);
         statusControl.ShowNames = false;
         Controls.Add (tabControl);
     }));
 }
예제 #9
0
        public void ShutdownHandler()
        {
            if (Playlist != null)
            {
                Playlist.ShutdownHandler();
                Playlist = null;
            }

            if (_chat != null)
            {
                _chat.ShutdownHandler();
                _chat = null;
            }
        }
예제 #10
0
 public void Connected(IChatProvider provider)
 {
     chatProvider = provider;
     Invoke(new MethodInvoker(() => {
         statusControl      = new ChatControl(chatProvider, null);
         statusControl.Dock = DockStyle.Fill;
         TabPage statusPage = new TabPage();
         statusPage.Text    = "Status";
         statusPage.Dock    = DockStyle.Fill;
         statusPage.Controls.Add(statusControl);
         tabControl.TabPages.Add(statusPage);
         statusControl.ShowNames = false;
         Controls.Add(tabControl);
     }));
 }
예제 #11
0
 public HudPanelFactory(INativeGraphicsManager nativeGraphicsManager,
                        IContentManagerProvider contentManagerProvider,
                        IHudControlProvider hudControlProvider,
                        INewsProvider newsProvider,
                        IChatProvider chatProvider,
                        ICharacterProvider characterProvider,
                        ICharacterInventoryProvider characterInventoryProvider,
                        IExperienceTableProvider experienceTableProvider,
                        IEOMessageBoxFactory messageBoxFactory,
                        ITrainingController trainingController)
 {
     _nativeGraphicsManager      = nativeGraphicsManager;
     _contentManagerProvider     = contentManagerProvider;
     _hudControlProvider         = hudControlProvider;
     _newsProvider               = newsProvider;
     _chatProvider               = chatProvider;
     _characterProvider          = characterProvider;
     _characterInventoryProvider = characterInventoryProvider;
     _experienceTableProvider    = experienceTableProvider;
     _messageBoxFactory          = messageBoxFactory;
     _trainingController         = trainingController;
 }
예제 #12
0
        protected override void Initiate(out LevelInfo info, out IChatProvider chatProvider)
        {
            info         = _generator.GetInfo();
            chatProvider = null;

            /*lock (genLock)
             * {
             *      while (_preGeneratedChunks.TryDequeue(out ChunkColumn chunk))
             *      {
             *              if (chunk != null)
             *              {
             *                      base.LoadChunk(chunk, chunk.X, chunk.Z, false);
             *                      LoadEntities(chunk);
             *              }
             *      }
             *
             *      _preGeneratedChunks = null;
             * }*/

            UpdateThread = new Thread(RunThread)
            {
                IsBackground = true
            };

            UpdateThread.Start();

            if (WorldReceiver is World world)
            {
                world.Player.CanFly               = true;
                world.Player.IsFlying             = true;
                world.Player.Controller.IsFreeCam = true;
            }

            WorldReceiver?.UpdatePlayerPosition(new PlayerLocation(GetSpawnPoint()));

            Log.Info($"World {info.LevelName} loaded!");
        }
예제 #13
0
 public void Subscribe()
 {
     Playlist.Subscribe(this);
     _chat = _chatProviderFactory.CreateChatProvider(thisChannel);
 }
예제 #14
0
 /// <summary>
 /// Initializes a new instance of the <see cref="AlfredPage" /> class.
 /// </summary>
 /// <param name="container">The container.</param>
 /// <param name="name">The name.</param>
 /// <param name="chatHandler">The input handler</param>
 internal ChatPage([NotNull] IObjectContainer container, [NotNull] string name, [NotNull] IChatProvider chatHandler)
     : base(container, name, "Chat")
 {
     _chatHandler = chatHandler;
 }
예제 #15
0
 /// <summary>
 ///     Registers the user statement handler as the framework's user statement handler.
 /// </summary>
 /// <param name="chatProvider">The user statement handler.</param>
 public void Register(IChatProvider chatProvider)
 {
     ChatProvider = chatProvider;
 }
예제 #16
0
 public ChatControl (IChatProvider provider, string chan) {
     channel = chan;
     chatProvider = provider;
     InitializeComponent ();
 }
예제 #17
0
 public ChatControl(IChatProvider provider, string chan)
 {
     channel      = chan;
     chatProvider = provider;
     InitializeComponent();
 }
예제 #18
0
 public ChatService(IChatProvider chatProvider)
 {
     _chatProvider = chatProvider;
 }
예제 #19
0
        public ChatPanel(INativeGraphicsManager nativeGraphicsManager,
                         IChatRenderableGenerator chatRenderableGenerator,
                         IChatProvider chatProvider,
                         IHudControlProvider hudControlProvider,
                         SpriteFont chatFont)
        {
            _nativeGraphicsManager   = nativeGraphicsManager;
            _chatRenderableGenerator = chatRenderableGenerator;
            _chatProvider            = chatProvider;
            _hudControlProvider      = hudControlProvider;
            _chatFont = chatFont;

            //abs coordiantes: 568 309
            _scrollBar = new ScrollBar(new Vector2(467, 2), new Vector2(16, 97), ScrollBarColors.LightOnMed, _nativeGraphicsManager)
            {
                LinesToRender = 7,
                Visible       = true
            };

            _chatRenderables = new List <IChatRenderable>();
            _state           = new ChatPanelStateCache();
            CurrentTab       = ChatTab.Local;

            var tabTexture = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 35);

            _smallSelected   = new SpriteSheet(tabTexture, new Rectangle(307, 16, 43, 16));
            _smallUnselected = new SpriteSheet(tabTexture, new Rectangle(264, 16, 43, 16));
            _largeSelected   = new SpriteSheet(tabTexture, new Rectangle(132, 16, 132, 16));
            _largeUnselected = new SpriteSheet(tabTexture, new Rectangle(0, 16, 132, 16));

            BackgroundImage = _nativeGraphicsManager.TextureFromResource(GFXTypes.PostLoginUI, 28);
            DrawArea        = new Rectangle(102, 330, BackgroundImage.Width, BackgroundImage.Height);

            _tabLabels = new Dictionary <ChatTab, IXNALabel>
            {
                { ChatTab.Local, new XNALabel(Constants.FontSize08)
                  {
                      Text = "scr", ForeColor = Color.White
                  } },
                { ChatTab.Global, new XNALabel(Constants.FontSize08)
                  {
                      Text = "glb"
                  } },
                { ChatTab.Group, new XNALabel(Constants.FontSize08)
                  {
                      Text = "grp"
                  } },
                { ChatTab.System, new XNALabel(Constants.FontSize08)
                  {
                      Text = "sys"
                  } },
                { ChatTab.Private1, new XNALabel(Constants.FontSize08)
                  {
                      Text = "[priv 1]", Visible = false
                  } },
                { ChatTab.Private2, new XNALabel(Constants.FontSize08)
                  {
                      Text = "[priv 2]", Visible = false
                  } }
            };

            _tabLabelClickableAreas = new Dictionary <ChatTab, Rectangle>
            {
                { ChatTab.Local, new Rectangle(0, 0, 43, 16).WithPosition(GetDestinationVectorForTab(ChatTab.Local)) },
                { ChatTab.Global, new Rectangle(0, 0, 43, 16).WithPosition(GetDestinationVectorForTab(ChatTab.Global)) },
                { ChatTab.Group, new Rectangle(0, 0, 43, 16).WithPosition(GetDestinationVectorForTab(ChatTab.Group)) },
                { ChatTab.System, new Rectangle(0, 0, 43, 16).WithPosition(GetDestinationVectorForTab(ChatTab.System)) },
                { ChatTab.Private1, new Rectangle(0, 0, 132, 16).WithPosition(GetDestinationVectorForTab(ChatTab.Private1)) },
                { ChatTab.Private2, new Rectangle(0, 0, 132, 16).WithPosition(GetDestinationVectorForTab(ChatTab.Private2)) },
            };

            foreach (var kvp in _tabLabels)
            {
                var startPos = GetDestinationVectorForTab(kvp.Key);
                kvp.Value.DrawPosition = startPos + new Vector2(14, 2);

                //note: these must be manually drawn so they appear on top of the tab graphics
                if (Game.Components.Contains(kvp.Value))
                {
                    Game.Components.Remove(kvp.Value);
                }
            }

            _closeButtonAreaForTab1 = new Rectangle(3, 3, 11, 11).WithPosition(GetDestinationVectorForTab(ChatTab.Private1));
            _closeButtonAreaForTab2 = new Rectangle(3, 3, 11, 11).WithPosition(GetDestinationVectorForTab(ChatTab.Private2));
        }
예제 #20
0
 public void Disconnect()
 {
     this.ConnectionLabel.Content = "Disconnected";
     this.UsersList.Items.Clear();
     chat_service = null;
 }
예제 #21
0
 protected abstract void Initiate(out LevelInfo info, out IChatProvider chatProvider);
예제 #22
0
 public ChatService(IAuthService authService, IChatProvider chatProvider, ApplicationDbContext context, IMapper mapper) : base(context, mapper)
 {
     _authService  = authService;
     _chatProvider = chatProvider;
 }
예제 #23
0
        public void Init(IWorldReceiver worldReceiver, IChatReceiver chat, out LevelInfo info, out IChatProvider chatProvider)
        {
            WorldReceiver = worldReceiver;
            ChatReceiver  = chat;

            Initiate(out info, out chatProvider);
        }