public void OnDataEvent(int socketID, int connectionId, byte[] buffer, NetworkError error)
    {
        DataEvent?.Invoke();

        var JsonText = Encoding.Unicode.GetString(buffer);

        NetworkMessage message = JsonConvert.DeserializeObject <NetworkMessage>(JsonText);

        switch (message.MessageType)
        {
        case DataEvents.ConnectionInfoRequest:     // Get connection info and save in connections pool
            //OnConnectionInfoEvent(hostId, connectionId, message, buffer, error);
            break;

        case DataEvents.PlayRequest:     // if connection response is ok, continue. Else, disconnect from node.
            PlayRequest?.Invoke();
            break;

        case DataEvents.PecasDoJogo:     // if connection response is ok, continue. Else, disconnect from node.
            try
            {
                DominoPecas dominoPecas = JsonConvert.DeserializeObject <DominoPecas>(message.Message.ToString());
                GlobalConfigInfo.blockchain.CreateTransaction(GlobalConfigInfo.CurrentAdversary.connectedNode.nickName, GlobalConfigInfo.ThisNode.nickName, dominoPecas);
                PecasDoJogo?.Invoke(dominoPecas);
            }
            catch (Exception e)
            {
                string exc = e.ToString();
            }
            break;

        case DataEvents.PlayerMove:     // call event to deal with this event and every gameplay script who sould know about network info should do your action
            try
            {
                Peca peca = JsonConvert.DeserializeObject <Peca>(message.Message.ToString());
                GlobalConfigInfo.blockchain.CreateTransaction(GlobalConfigInfo.CurrentAdversary.connectedNode.nickName, GlobalConfigInfo.ThisNode.nickName, peca);
                PecaEvent?.Invoke(peca);
            }
            catch (Exception e)
            {
                string exc = e.ToString();
            }

            //PlayerMove?.Invoke();

            break;

        case DataEvents.EndGame:     // call event to deal with this event and every gameplay script who sould know about network info should do your action
            EndGame?.Invoke();
            break;
        }

        print("|Data event: " +
              "/n|HostId: " + socketID +
              "/n|ConnectionId : " + connectionId +
              "/n|Error: " + error.ToString());
    }
        public void Play_Pause_Video()
        {
            DataReqEventArgs eData = new DataReqEventArgs();

            if (PlayCtrlContent == "Play")
            {
                PlayRequest?.Invoke(this, eData);
                PlayCtrlContent = "Pause";
            }
            else
            {
                PauseRequest?.Invoke(this, eData);
                PlayCtrlContent = "Play";
            }
        }
 private void ButtonPlayScissors_Click(object sender, EventArgs e)
 {
     textboxClientPlay.Text = "Scissors";
     DisablePlayButtons();
     PlayRequest?.Invoke(3);
 }
 private void ButtonPlayRock_Click(object sender, EventArgs e)
 {
     textboxClientPlay.Text = "Rock";
     DisablePlayButtons();
     PlayRequest?.Invoke(1);
 }
 private void ButtonPlayPaper_Click(object sender, EventArgs e)
 {
     textboxClientPlay.Text = "Paper";
     DisablePlayButtons();
     PlayRequest?.Invoke(2);
 }
 public static void Play(Media media, MediaQueue queue = default)
 {
     PlayRequest?.Invoke(queue, media);
 }
Exemple #7
0
 protected virtual void OnPlayRequest(PlaybackModel e)
 {
     PlayRequest?.Invoke(this, e);
 }
 public void Load_Video()
 {
     // a request to play is used to make the video load, (couldn't find better...)
     // then upon MediaOpened event, request a Stop!
     PlayRequest?.Invoke(this, new DataReqEventArgs());
 }