Ejemplo n.º 1
0
    public void Send()
    {
        var text = inputField.text;

        if (text == string.Empty)
        {
            return;
        }

        print("sending: '" + text + "'");

        Message message = new Message(username.options[username.value].text, text, DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).Ticks, Platform.Mockup);

        try
        {
            ChatAPI.NotifyNewMessageToListeners(message);
        }
        catch (Exception e)
        {
            throw e;
        }
        finally
        {
            inputField.text = string.Empty;
            inputField.ActivateInputField();

            if (chatHistory)
            {
                chatHistory.Add(message);
            }
        }
    }
    public void DoCommand(string username, int platformCode, ICommand command)
    {
        if (command == null)
        {
            return;
        }

        if (m_debug)
        {
            Debug.Log(string.Format("GameManager12:DoCommand() => username:{0} feedback:{1} response:{2}", username, command.feedbackUser, command.response));
        }

        Platform platform = (Platform)platformCode;

        if (command.feedbackUser)
        {
            Message msg = new Message("Game Admin", command.response, Message.GetCurrentTimeUTC(), Platform.Game);
            ChatAPI.SendMessageToUser(username, platform, msg);
        }
        else
        {
            if (command.response == "!START" && !gameIsStarted)
            {
                gameIsStarted = true;
                m_physicsManager.StartGame();
            }
            string userId           = platformCode + " " + username;
            string formattedCommand = command.response.Substring(1).ToUpper();

            m_physicsManager.SetCommandFromPlayer(userId, formattedCommand);
        }
    }
Ejemplo n.º 3
0
 protected void Start()
 {
     ChatAPI.AddListener(HandleMessage);
     PhysicsManager.AddEndGameTimerListener(DoEndGame);
     ItemEvent.AddPickupListener(HandleEvent);
     ItemEvent.AddUseListener(HandleUse);
 }
Ejemplo n.º 4
0
 private void txtMsgContents_KeyDown(object sender, KeyEventArgs e)
 {
     if (e.KeyCode == Keys.Enter)
     {
         ChatAPI.SendMessage(txtMsgContents, txtSentMessages);
         e.SuppressKeyPress = true;
     }
 }
 void Start()
 {
     ChatAPI.AddGameToServerListener(SendMessage);
     ChatAPI.AddGameToServerListener(SendMessageToAll);
     if (debug)
     {
         StartCoroutine(Test());
     }
 }
    // Use this for initialization
    IEnumerator Test()
    {
        while (true)
        {
            yield return(new WaitForSeconds(5));

            ChatAPI.SendMessageToUser("drnd93", Platform.Twitch, new Message("GameMaster", "Bonjour toi", Message.GetCurrentTimeUTC(), Platform.Game));
            ChatAPI.SendMessageToEveryUsers(new Message("GameMaster", "T:" + Message.GetCurrentTimeUTC(), Message.GetCurrentTimeUTC(), Platform.Game));
        }
    }
Ejemplo n.º 7
0
    protected void Start()
    {
        ChatAPI.AddListener(HandleMessage);
        SpecialAPI.AddListener(HandleEvent);


        //Special spe = new Special();
        //spe.m_playerCharacter = new PlayerCharacter();
        //spe.m_typeSpecial = Special.e_specialType.PARCHEMENT;
        //SpecialAPI.NotifyNewSpecial(spe);
    }
Ejemplo n.º 8
0
        static void Main()
        {
            ChatAPI coreChat = new ChatAPI();

            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Login loginForm = new Login(coreChat);

            loginForm.ShowDialog();
            //Form1 mainForm = new Form1();
            //mainForm.BindChatAPI(coreChat);
            //coreChat.ChatFormWindow = mainForm;
            //mainForm.ShowDialog();
        }
Ejemplo n.º 9
0
 // Use this for initialization
 void Start()
 {
     if (trackReceivedMessage)
     {
         ChatAPI.AddListener(DisplayMessageWhenReceived);
     }
     if (trackSendingMessageToUser)
     {
         ChatAPI.AddGameToServerListener(DisplayMessageWhenSend);
     }
     if (trackSendingMessageToAll)
     {
         ChatAPI.AddGameToServerListener(DisplayMessageWhenSendToAll);
     }
 }
Ejemplo n.º 10
0
    private void NotifyChatAPI(string line)
    {
        if (debugPrintAll)
        {
            print("Trying to notify");
        }

        FBMessage fb_msg = JsonUtility.FromJson <FBMessage>(line);

        DateTime unixStart = new DateTime(1970, 1, 1, 0, 0, 0, 0, System.DateTimeKind.Utc);
        long     timestamp = (long)(DateTime.Now.ToUniversalTime() - unixStart).TotalSeconds;

        // Linking the two classes together, oops!

        Message msg = new Message(fb_msg.from.name, fb_msg.message, timestamp, Platform.Facebook);

        ChatAPI.NotifyNewMessageToListeners(msg);
    }
Ejemplo n.º 11
0
    private void SendNextMessage()
    {
        if (_messageToSend.Count == 0)
        {
            throw new System.Exception("List must not be null, you damn morron");
        }

        MessageToSend toSend = _messageToSend[_messageIndex];

        _messageIndex++;
        if (_messageIndex >= _messageToSend.Count)
        {
            _messageIndex = 0;
        }

        Message msg = new Message(
            toSend._userName, toSend._message
            , GetTimestamp(DateTime.Now), Platform.Mockup
            );

        ChatAPI.NotifyNewMessageToListeners(msg);
    }
Ejemplo n.º 12
0
    private void HandleMessage(Message message)
    {
        ICommand command = m_commandManager.Parse(
            message.GetUserName(),
            (int)message.GetPlatform(),
            message.GetMessage(),
            message.GetTimestamp()
            );

        if (command == null)
        {
            return;
        }

        if (command.feedbackUser)
        {
            m_input.SendFeedback(command);

            Message msg = new Message("Game Admin", command.response, Message.GetCurrentTimeUTC(), Platform.Game);

            //ChatAPI.SendMessageToEveryUsers(msg);
            ChatAPI.SendMessageToUser(message.GetUserName(), message.GetPlatform(), msg);
        }
        else
        {
            if (command.response == "!START")
            {
                List <string> playerList = new List <string>(m_commandManager.userDataBase.Keys);
                m_gameEngine.AssignFactionToPlayers(playerList);
            }

            string userId           = (int)message.GetPlatform() + " " + message.GetUserName();
            string formattedCommand = command.response.Substring(1).ToUpper();

            m_gameEngine.GetCommandFromPlayer(userId, formattedCommand);
        }
    }
Ejemplo n.º 13
0
 public Login(ChatAPI api)
 {
     coreChat = api;
     myColor  = System.Drawing.Color.SkyBlue;
     InitializeComponent();
 }
Ejemplo n.º 14
0
 private void Start()
 {
     ChatAPI.AddListener(RedirectMessage);
     ChatAPI.IgnoreMockUp = _ignoreMockPrevious = _ignoreMock;
 }
 protected void Start()
 {
     ChatAPI.AddListener(HandleMessage);
     //PhysicsManager.AddEndGameTimerListener(TimerFunction);
     ItemEvent.AddPickupListener(HandleEvent);
 }
Ejemplo n.º 16
0
 private void btnSendMSG_Click(object sender, EventArgs e)
 {
     ChatAPI.SendMessage(txtMsgContents, txtSentMessages);
 }
Ejemplo n.º 17
0
    private void SendMessageToPlayer(Platform platform, string playerName, string message)
    {
        Message msg = new Message(playerName, message, GetTimestamp(), platform);

        ChatAPI.SendMessageToUser(playerName, platform, msg);
    }
Ejemplo n.º 18
0
 // Use this for initialization
 void Start()
 {
     ChatAPI.AddListener(CheckForUserAskingTime);
 }
    // Update is called once per frame
    void GenerateAndSendMessage(string pseudo, string message)
    {
        Message msg = new Message(pseudo, message, GetTime(), Platform.Twitch);

        ChatAPI.NotifyNewMessageToListeners(msg);
    }
Ejemplo n.º 20
0
 public void BindChatAPI(ChatAPI chatAPI)
 {
     chatCore = chatAPI;
 }
Ejemplo n.º 21
0
    private void SendWhisperToUser(string userToWhisper, string theWhisper)
    {
        Message whisper = new Message(userToWhisper, theWhisper, Message.GetCurrentTimeUTC(), Platform.Game);

        ChatAPI.SendMessageToUser(userToWhisper, Platform.Twitch, whisper);
    }
Ejemplo n.º 22
0
 public Login(ChatAPI api)
 {
     coreChat = api;
     InitializeComponent();
 }