예제 #1
0
        private void HandleOperationResponseCreateChatChannel(IRpcProtocol protocol, OperationResponse operationResponse)
        {
            var response = new CreateChannelResponse(protocol, operationResponse);

            if (!response.IsValid)
            {
                _logger.ErrorFormat("[HandleOperationResponseCreateChatChannel]: Received an invalid {0} (Error={1})", response.GetType(), response.GetErrorMessage());
                return;
            }

            ChannelCreatedCallback callback;

            lock (channelCreatedCallbacks)
                if (channelCreatedCallbacks.TryGetValue(response.CallbackId, out callback))
                {
                    channelCreatedCallbacks.Remove(response.CallbackId);
                }

            if (callback == null)
            {
                _logger.DebugFormat("Received a(n) {0} which does not have an EventHandler", response.GetType());
                return;
            }

            callback(response.ChannelId);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateChannelResponse response = new CreateChannelResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("channelArn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ChannelArn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("channelName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ChannelName = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("retentionPeriod", targetDepth))
                {
                    var unmarshaller = RetentionPeriodUnmarshaller.Instance;
                    response.RetentionPeriod = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
예제 #3
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateChannelResponse response = new CreateChannelResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("channel", targetDepth))
                {
                    var unmarshaller = ChannelUnmarshaller.Instance;
                    response.Channel = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("streamKey", targetDepth))
                {
                    var unmarshaller = StreamKeyUnmarshaller.Instance;
                    response.StreamKey = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public static CreateChannelResponse Unmarshall(UnmarshallerContext context)
        {
            CreateChannelResponse createChannelResponse = new CreateChannelResponse();

            createChannelResponse.HttpResponse = context.HttpResponse;
            createChannelResponse.RequestId    = context.StringValue("CreateChannel.RequestId");
            createChannelResponse.Success      = context.BooleanValue("CreateChannel.Success");
            createChannelResponse.ErrorCode    = context.IntegerValue("CreateChannel.ErrorCode");

            CreateChannelResponse.CreateChannel_Result result = new CreateChannelResponse.CreateChannel_Result();
            result.ChannelId             = context.StringValue("CreateChannel.Result.ChannelId");
            result.Name                  = context.StringValue("CreateChannel.Result.Name");
            result.ConsortiumId          = context.StringValue("CreateChannel.Result.ConsortiumId");
            result.State                 = context.StringValue("CreateChannel.Result.State");
            result.OwnerBid              = context.StringValue("CreateChannel.Result.OwnerBid");
            result.OwnerUid              = context.IntegerValue("CreateChannel.Result.OwnerUid");
            result.OwnerName             = context.StringValue("CreateChannel.Result.OwnerName");
            result.MemberCount           = context.IntegerValue("CreateChannel.Result.MemberCount");
            result.ChaincodeCount        = context.IntegerValue("CreateChannel.Result.ChaincodeCount");
            result.BlockCount            = context.IntegerValue("CreateChannel.Result.BlockCount");
            result.RequestId             = context.StringValue("CreateChannel.Result.RequestId");
            result.CreateTime            = context.StringValue("CreateChannel.Result.CreateTime");
            result.UpdateTime            = context.StringValue("CreateChannel.Result.UpdateTime");
            result.ConsortiumName        = context.StringValue("CreateChannel.Result.ConsortiumName");
            createChannelResponse.Result = result;

            return(createChannelResponse);
        }
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateChannelResponse response = new CreateChannelResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("description", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Description = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("egressAccessLogs", targetDepth))
                {
                    var unmarshaller = EgressAccessLogsUnmarshaller.Instance;
                    response.EgressAccessLogs = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("hlsIngest", targetDepth))
                {
                    var unmarshaller = HlsIngestUnmarshaller.Instance;
                    response.HlsIngest = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("id", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Id = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ingressAccessLogs", targetDepth))
                {
                    var unmarshaller = IngressAccessLogsUnmarshaller.Instance;
                    response.IngressAccessLogs = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("tags", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.Tags = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
        public static CreateChannelResponse Unmarshall(UnmarshallerContext context)
        {
            CreateChannelResponse createChannelResponse = new CreateChannelResponse();

            createChannelResponse.HttpResponse = context.HttpResponse;
            createChannelResponse.RequestId    = context.StringValue("CreateChannel.RequestId");
            createChannelResponse.ChannelKey   = context.StringValue("CreateChannel.ChannelKey");
            createChannelResponse.Nonce        = context.StringValue("CreateChannel.Nonce");
            createChannelResponse.Timestamp    = context.IntegerValue("CreateChannel.Timestamp");

            return(createChannelResponse);
        }
예제 #7
0
        // PartyService just uses ChannelService to create a new channel for the party.
        public override void CreateChannel(IRpcController controller, CreateChannelRequest request, Action <CreateChannelResponse> done)
        {
            Logger.Trace("CreateChannel()");
            var channel = ChannelManager.CreateNewChannel((BNetClient)this.Client, request.ObjectId);
            var builder = CreateChannelResponse.CreateBuilder()
                          .SetObjectId(channel.DynamicId)
                          .SetChannelId(channel.BnetEntityId);

            done(builder.Build());

            // Set the client that requested the creation of channel as the owner
            channel.SetOwner((BNetClient)Client);

            Logger.Warn("Created a new channel {0}:{1} for toon {2}", channel.BnetEntityId.High, channel.BnetEntityId.Low, Client.CurrentToon.Name);
        }
예제 #8
0
        static ChannelAuth CreateChannel(
            string appId, string channelId,
            string regionId, string endpoint, string accessKeyId,
            string accessKeySecret)
        {
            try
            {
                IClientProfile profile = DefaultProfile.GetProfile(
                    regionId, accessKeyId, accessKeySecret);
                IAcsClient client = new DefaultAcsClient(profile);

                CreateChannelRequest request = new CreateChannelRequest();
                request.AppId     = appId;
                request.ChannelId = channelId;

                // Strongly recomment to set the RTC endpoint,
                // because the exception is not the "right" one if not set.
                // For example, if access-key-id is invalid:
                //      1. if endpoint is set, exception is InvalidAccessKeyId.NotFound
                //      2. if endpoint isn't set, exception is SDK.InvalidRegionId
                // that's caused by query endpoint failed.
                // @remark SDk will cache endpoints, however it will query endpoint for the first
                //      time, so it's good for performance to set the endpoint.
                DefaultProfile.AddEndpoint(regionId, regionId, request.Product, endpoint);

                // Use HTTP, x3 times faster than HTTPS.
                request.Protocol = Aliyun.Acs.Core.Http.ProtocolType.HTTP;

                CreateChannelResponse response = client.GetAcsResponse(request);

                ChannelAuth auth = new ChannelAuth();
                auth.AppId      = appId;
                auth.ChannelId  = channelId;
                auth.Nonce      = response.Nonce;
                auth.Timestamp  = (Int64)response.Timestamp;
                auth.ChannelKey = response.ChannelKey;
                auth.Recovered  = false;
                auth.RequestId  = response.RequestId;

                return(auth);
            }
            catch (Exception ex)
            {
                return(RecoverForError(ex, appId, channelId));
            }
        }
예제 #9
0
        public Task <CreateChannelResponse> CreateChannel(SlackChannelName channelName)
        {
            CreatedChannelName = channelName;

            var channel = new ChannelDto
            {
                Id   = new ChannelId(Guid.NewGuid().ToString()),
                Name = channelName
            };

            var createChannelResponse = new CreateChannelResponse
            {
                Ok      = true,
                Channel = channel
            };


            return(Task.FromResult(createChannelResponse));
        }
예제 #10
0
        /// <summary>
        /// Unmarshaller the response from the service to the response class.
        /// </summary>
        /// <param name="context"></param>
        /// <returns></returns>
        public override AmazonWebServiceResponse Unmarshall(JsonUnmarshallerContext context)
        {
            CreateChannelResponse response = new CreateChannelResponse();

            context.Read();
            int targetDepth = context.CurrentDepth;

            while (context.ReadAtDepth(targetDepth))
            {
                if (context.TestExpression("Arn", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.Arn = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ChannelName", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ChannelName = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("ChannelState", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.ChannelState = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("CreationTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.CreationTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("LastModifiedTime", targetDepth))
                {
                    var unmarshaller = DateTimeUnmarshaller.Instance;
                    response.LastModifiedTime = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("Outputs", targetDepth))
                {
                    var unmarshaller = new ListUnmarshaller <ResponseOutputItem, ResponseOutputItemUnmarshaller>(ResponseOutputItemUnmarshaller.Instance);
                    response.Outputs = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("PlaybackMode", targetDepth))
                {
                    var unmarshaller = StringUnmarshaller.Instance;
                    response.PlaybackMode = unmarshaller.Unmarshall(context);
                    continue;
                }
                if (context.TestExpression("tags", targetDepth))
                {
                    var unmarshaller = new DictionaryUnmarshaller <string, string, StringUnmarshaller, StringUnmarshaller>(StringUnmarshaller.Instance, StringUnmarshaller.Instance);
                    response.Tags = unmarshaller.Unmarshall(context);
                    continue;
                }
            }

            return(response);
        }
예제 #11
0
        public override void CreateChannel(Google.ProtocolBuffers.IRpcController controller, bnet.protocol.channel.CreateChannelRequest request, Action <bnet.protocol.channel.CreateChannelResponse> done)
        {
            var channel_id = bnet.protocol.EntityId.CreateBuilder().SetLow(11233645142038554527).SetHigh(433661094618860925).Build();
            var response   = CreateChannelResponse.CreateBuilder();

            response.SetObjectId(1234);
            response.SetChannelId(channel_id);
            done(response.Build());

            /*var field1 = bnet.protocol.presence.Field.CreateBuilder()
             *      .SetKey(bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(3).SetIndex(0))
             *      .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetBoolValue(true));
             *
             * var field2 = bnet.protocol.presence.Field.CreateBuilder()
             *      .SetKey(bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(10).SetIndex(0))
             *      .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetIntValue(1315530390868296));
             *
             * var field3 = bnet.protocol.presence.Field.CreateBuilder()
             *      .SetKey(bnet.protocol.presence.FieldKey.CreateBuilder().SetProgram(16974).SetGroup(3).SetField(11).SetIndex(0))
             *      .SetValue(bnet.protocol.attribute.Variant.CreateBuilder().SetMessageValue(
             *              ByteString.CopyFrom(new byte[] { 0x9, 0x46, 0xee, 0x00, 0x00, 0x00, 0x00, 0x00, 0x4, 0x11, 0xdd, 0xb4, 0x63, 0xe7, 0x82, 0x44, 0x68, 0x4e })));
             *
             *
             * var fieldOperation1 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field1);
             * var fieldOperation2 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field2);
             * var fieldOperation3 = bnet.protocol.presence.FieldOperation.CreateBuilder().SetField(field3);
             *
             * var state = bnet.protocol.presence.ChannelState.CreateBuilder()
             *      .SetEntityId(channel_id)
             *      .AddFieldOperation(fieldOperation1)
             *      .AddFieldOperation(fieldOperation2)
             *      .AddFieldOperation(fieldOperation3);
             *
             *
             * var channelState = bnet.protocol.channel.ChannelState.CreateBuilder().SetExtension(bnet.protocol.presence.ChannelState.Presence, state.Build());
             * var notif = bnet.protocol.channel.UpdateChannelStateNotification.CreateBuilder().SetStateChange(channelState).Build();
             *
             * var serv = client.GetImportedService<ChannelSubscriber>();
             * serv.NotifyUpdateChannelState(null, notif, d => { });*/

            var notification = new AddNotification.Builder {
                Self = new Member.Builder {
                    Identity = new Identity.Builder {
                        AccountId = new EntityId.Builder {
                            High = 0x100000000000000,
                            Low  = 1234
                        }.Build(),
                GameAccountId = new EntityId.Builder {
                            High = 0x200006200004433,
                            Low  = 1234,
                        }.Build(),
                ToonId = new EntityId.Builder {
                            High = 0x300016200004433,
                            Low  = 2,
                        }.Build()
                    }.Build(),
                State = new MemberState.Builder {
                        Privileges = 64511,
                    }.AddRole(2).Build(),
                }.Build(),

                ChannelState = new ChannelState.Builder {
                    MaxMembers     = 8,
                    MinMembers     = 1,
                    MaxInvitations = 12,
                    PrivacyLevel   = ChannelState.Types.PrivacyLevel.PRIVACY_LEVEL_OPEN_INVITATION
                }.Build()
            }.AddMember(new Member.Builder {
                Identity = new Identity.Builder {
                    ToonId = new EntityId.Builder {
                        High = 0x300016200004433,
                        Low  = 2,
                    }.Build()
                }.Build(),
                State = new MemberState.Builder {
                    Privileges = 64511,
                }.AddRole(2).Build(),
            }.Build());

            client.GetImportedService <ChannelSubscriber>().NotifyAdd(null, notification.Build(), null);
        }