protected override Task AuthorizeAsync(IChatCredential credential) { var model = new GGMessage <ReqGGChatAuth> { Type = "auth" }; if (credential == null) { model.Data.UserId = 0; } else { if (int.TryParse(credential.User, out int userId)) { model.Data.UserId = userId; model.Data.Token = credential.Token.Unsecure(); } else { throw new InvalidOperationException( "Invalid conversion IChatCredential.User to int."); } } return(SendModelAsync(model)); }
protected override Task InternalUnJoinChannel(Channel channel) { var model = new GGMessage <ResGGChatUnJoin> { Type = "unjoin", Data = { ChannelId = channel.Id.Value } }; return(SendModelAsync(model)); }
protected override Task InternalSendMessageAsync(string text, Channel channel) { // TODO : add IChatOptions var model = new GGMessage <ReqGGSendMessage>() { Type = "send_message", Data = { ChannelId = channel.Id.Value, Mobile = 0, Text = text // icon = ??? // mobile = ??? // color = ??? } }; return(SendModelAsync(model)); }
protected async override Task InternalJoinChannel(Channel channel) { if (channel.Id.HasValue) { var model = new GGMessage <ReqGGChatJoin> { Type = "join", Data = { ChannelId = channel.Id.Value, Hidden = 0 } }; await SendModelAsync(model).ConfigureAwait(false); } else { throw new InvalidOperationException("ChannelId is null."); } }