protected override void SocialSharePublish(string channelName, string channelUrl, string message, SocialBase.SocialShareHandler callBack) { var social = SocialViewModel.Instance.GetRecord(SocialType.TENCENT); OAuthConfigruation.AccessToken = new AccessToken(social.AcessToken); var share = new TService(); var arg = new ServiceArgument() { Content = message //Url = channelUrl }; try { share.Add(arg, obj => { if (obj.Succeed) { callBack(true, string.Empty); } else { callBack(false, obj.InnerException.Message); } }); } catch (Exception ex) { callBack(false, ex.Message); } }
protected override void SocialSharePublish(string channelName, string channelUrl, string message, SocialBase.SocialShareHandler callBack) { var social = SocialViewModel.Instance.GetRecord(SocialType.TENCENT); OAuthConfigruation.AccessToken = new AccessToken(social.AcessToken); var share = new TService(); var arg = new ServiceArgument() { Content = message //Url = channelUrl }; try { share.Add(arg, obj => { if (obj.Succeed) callBack(true, string.Empty); else callBack(false, obj.InnerException.Message); }); } catch (Exception ex) { callBack(false, ex.Message); } }
public void ClientSendToServer() { const string hostName = "127.0.0.1"; const ushort port = 8889; using (IService clientService = new TService()) { using (IService serverService = new TService(hostName, 8889)) { Task task1 = Task.Factory.StartNew(() => { while (!this.isClientStop) { clientService.Update(); } }, TaskCreationOptions.LongRunning); Task task2 = Task.Factory.StartNew(() => { while (!this.isServerStop) { serverService.Update(); } }, TaskCreationOptions.LongRunning); // 往server host线程增加事件,accept serverService.Add(() => this.ServerEvent(serverService)); // 往client host线程增加事件,client线程连接server clientService.Add(() => this.ClientEvent(clientService, hostName, port)); this.barrier.SignalAndWait(); serverService.Add(() => { this.isServerStop = true; }); clientService.Add(() => { this.isClientStop = true; }); Task.WaitAll(task1, task2); } } }