public static IPushingHub CreatePushingHub(this ILubalaChannel channel, Action <IHubBuilder> configurer) { Log.Logger.Debug("creating pushing hub."); var builder = new HubBuilder(channel); configurer(builder); var pushingHub = builder.BuildPushingHub(); Log.Logger.Debug("creating pushing hub done."); return(pushingHub); }
private WechatToken RetrieveTokenRemotly(string appId, string appSecret, ILubalaChannel channel) { var token = channel.Request <Token>("/cgi-bin/token", context => { context .DisableAutoToken() .AddParam("grant_type", "client_credential") .AddParam("appid", appId) .AddParam("secret", appSecret); }); return(new WechatToken(token, DateTimeOffset.UtcNow)); }
public WechatToken RetrieveToken(string appId, string appSecret, ILubalaChannel channel) { lock (_locker) { WechatToken token; if (_tokens.TryGetValue(appId, out token)) { if (token.ExpiredDateTime < DateTimeOffset.UtcNow) { Log.Logger.Info("token expired, retrieving now."); token = RetrieveTokenRemotly(appId, appSecret, channel); _tokens[appId] = token; } } else { Log.Logger.Info("retrieving token from wechat server."); token = RetrieveTokenRemotly(appId, appSecret, channel); _tokens.Add(appId, token); } return(token); } }
public HubBuilder(ILubalaChannel channel) { _context = new HubContext { Channel = channel, Resolver = channel.Resolver }; }