示例#1
0
 /// <summary>
 /// Constructor for the GameModel
 /// </summary>
 /// <param name="numSection">Section-No. to display by client</param>
 public GameModel(int numSection)
 {
     _numSection = numSection;
     this.ClientChannelHandler = ClientChannelHandler.getInstance();
     AddListener();
     ClientChannelHandler.sendPlayerReadyMessage();
 }
        public override void ChannelActive(IChannelHandlerContext context)
        {
            try
            {
                channel = context.Channel;
                if (ClientChannelHandler != null)
                {
                    ClientChannelHandler.ClientChannelConnected(new ClientChannelConnectedEventArgs
                    {
                        //ChannelId = ClientChannelConfigurationManager.Instance.Configurations.ChannelId,
                        //ChannelKey = ChannelKey,
                        Context = new ClientContext(context)
                    });
                }

                //var msg = new RegisterMessage
                //{
                //    ChannelKey = ChannelKey
                //};
                //var registerMessage = JsonConvert.SerializeObject(msg);

                //context.WriteAndFlushAsync(registerMessage);
                Log?.Verbose(className, "ChannelActive",
                             "Connected with Server");
            }
            catch (Exception ex)
            {
                LogException(context, ex, "ChannelActive");
            }
        }
示例#3
0
 /// <summary>
 /// Constructor for the EditorModel
 /// </summary>
 /// <param name="sess">Session to load</param>
 public EditorModel(SessionDTO sess)
 {
     _clientChannelHandler = ClientChannelHandler.getInstance();
     _map       = new Map();
     curSession = sess;
     AddListener();
     Width    = 1920;
     _texture = cleanBrush;
 }
 private void LogException(IChannelHandlerContext context, Exception ex, string methodName)
 {
     if (ClientChannelHandler != null)
     {
         ClientChannelHandler.ClientChannelError(new ClientChannelErrorEventArgs
         {
             //ChannelId = ClientChannelConfigurationManager.Instance.Configurations.ChannelId,
             //ChannelKey = ChannelKey,
             Context = new ClientContext(context),
             Message = ex.Message,
             Details = ex.ToString()
         });
     }
     Log?.Error(className, methodName,
                string.Format("Message: {0}, Details: {1}", ex.Message, ex.ToString()));
 }
 public override void ChannelInactive(IChannelHandlerContext context)
 {
     try
     {
         channel = context.Channel;
         if (ClientChannelHandler != null)
         {
             ClientChannelHandler.ClientChannelDisconnected(new ClientChannelDisconnectedEventArgs
             {
                 //ChannelId = ClientChannelConfigurationManager.Instance.Configurations.ChannelId,
                 //ChannelKey = ChannelKey,
                 Context = new ClientContext(context)
             });
         }
     }
     catch (Exception ex)
     {
         LogException(context, ex, "ChannelInactive");
     }
 }
 protected override void ChannelRead0(IChannelHandlerContext context, string message)
 {
     try
     {
         channel = context.Channel;
         if (ClientChannelHandler != null)
         {
             ClientChannelHandler.ClientChannelDataReceived(new ClientChannelDataReceivedEventArgs
             {
                 //ChannelKey = ChannelKey,
                 //ChannelId = ClientChannelConfigurationManager.Instance.Configurations.ChannelId,
                 Context = new ClientContext(context),
                 Message = message
             });
         }
     }
     catch (Exception ex)
     {
         LogException(context, ex, "ChannelRead0");
     }
 }
 public override void ExceptionCaught(IChannelHandlerContext context, Exception exception)
 {
     base.ExceptionCaught(context, exception);
     try
     {
         channel = context.Channel;
         if (ClientChannelHandler != null)
         {
             ClientChannelHandler.ClientChannelError(new ClientChannelErrorEventArgs
             {
                 //ChannelKey = ChannelKey,
                 //ChannelId = ClientChannelConfigurationManager.Instance.Configurations.ChannelId,
                 Context = new ClientContext(context),
                 Message = exception.Message,
                 Details = exception.ToString()
             });
         }
         //context.CloseAsync();
     }
     catch (Exception ex)
     {
         LogException(context, ex, "ExceptionCaught");
     }
 }
 public QuitGameDialogViewModel()
 {
     clientChannelHandler = ClientChannelHandler.getInstance();
 }