Ejemplo n.º 1
0
        private static void WebClient_UploadDataCompleted(object sender, UploadDataCompletedEventArgs e)
        {
            try
            {
                string responseString = Encoding.UTF8.GetString(e.Result);

                if (OnSubmitSuccess != null)
                {
                    OnSubmitSuccess.Invoke(sender, new MessageEventArgs {
                        message = responseString
                    });
                }
            }
            catch (Exception ex)
            {
                if (OnSubmitError != null)
                {
                    OnSubmitError.Invoke(sender, new System.IO.ErrorEventArgs(ex));
                }
            }

            _isHandlingRequest = false;

            ProcessQueue();
        }
Ejemplo n.º 2
0
        public static bool SubmitGameEvent(string queueName, int eventId, GameEvent gameevent, KeyValuePair <string, string>[] properties = null, string sessionId = null)
        {
            try
            {
                GamePacket packet;

                lock (_syncRoot)
                {
                    // add the properties
                    var collection = new Dictionary <string, string>();

                    if (properties != null)
                    {
                        foreach (var property in properties)
                        {
                            collection.Add(property.Key, property.Value);
                        }
                    }

                    collection.Add(GamePacket.VERSION, GamePacket.Namespace);

                    packet = new GamePacket
                    {
                        Queue                = queueName,
                        GameId               = CommonConfiguration.Instance.GameId,
                        PlayerId             = CommonConfiguration.Instance.PlayerId,
                        Correlation          = correlation,
                        PacketNumber         = _packet++,
                        PacketCreatedUTCDate = DateTime.UtcNow,
                        GameEvent            = gameevent,
                        EventId              = eventId,
                        Properties           = collection
                    };

                    _packets.Enqueue(packet);
                }

                ProcessQueue();
            }
            catch (Exception ex)
            {
                if (OnSubmitError != null)
                {
                    OnSubmitError.Invoke(null, new ErrorEventArgs(ex));
                }

                return(false);
            }
            return(true);
        }