private async void RegisterDisconnectEvent(IChatHub streamingClient) { try { // you can wait disconnected event await streamingClient.WaitForDisconnect(); } catch (Exception e) { Debug.LogError(e); } finally { // try-to-reconnect? logging event? close? etc... Debug.Log($"disconnected from the server."); if (this.isSelfDisConnected) { // there is no particular meaning await Task.Delay(2000); // reconnect await this.ReconnectServerAsync(); } } }
public LoginVM(IAccount account, IChatHub chat, IAbstractFactory <Window> abstractFactory) : base(account, chat, abstractFactory) { UserName = Properties.UserSettings.Default.Login; Password = Properties.UserSettings.Default.Password; RememberMe = Properties.UserSettings.Default.RememberMe; _errors.Clear(); }
private void InitializeClient() { // Initialize the Hub this.channel = new Channel("localhost:12345", ChannelCredentials.Insecure); this.streamingClient = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(this.channel, this); this.client = MagicOnionClient.Create <IChatService>(this.channel); }
public ChatRoomService(IChatRoomRepository chatRoomRepository, IMessageRepository messageRepository, IChatHub chatHub, UserManager <User> userManager) { _chatRoomRepository = chatRoomRepository; _messageRepository = messageRepository; _chatHub = chatHub; _userManager = userManager; }
public async void ReconnectInitializedServer() { if (this.channel != null) { var chan = this.channel; if (chan == Interlocked.CompareExchange(ref this.channel, null, chan)) { await chan.ShutdownAsync(); this.channel = null; } } if (this.streamingClient != null) { var streamClient = this.streamingClient; if (streamClient == Interlocked.CompareExchange(ref this.streamingClient, null, streamClient)) { await streamClient.DisposeAsync(); this.streamingClient = null; } } if (this.channel == null && this.streamingClient == null) { this.InitializeClient(); this.InitializeUi(); } }
public UserVM(IChatHub chat, IClone <UserModel> clone, IFile file) { _chat = chat; _clone = clone; _file = file; _chat.ConnectionStarted += GetCurrentUser; }
private async Task InitializeClientAsync() { // Initialize the Hub this.channel = new Channel("localhost", 5000, ChannelCredentials.Insecure); // for SSL/TLS connection //var cred = new SslCredentials(File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "server.crt"))); //this.channel = new Channel("dummy.example.com", 5000, cred); // local tls //this.channel = new Channel("your-nlb-domain.com", 5000, new SslCredentials()); // aws nlb tls while (!shutdownCancellation.IsCancellationRequested) { try { Debug.Log($"Connecting to the server..."); this.streamingClient = await StreamingHubClient.ConnectAsync <IChatHub, IChatHubReceiver>(this.channel, this, cancellationToken : shutdownCancellation.Token); this.RegisterDisconnectEvent(streamingClient); Debug.Log($"Connection is established."); break; } catch (Exception e) { Debug.LogError(e); } Debug.Log($"Failed to connect to the server. Retry after 5 seconds..."); await Task.Delay(5 * 1000); } this.client = MagicOnionClient.Create <IChatService>(this.channel); }
public AddUserVM(IChatHub chat, IFile file, IAbstractFactory <ChatVM> abstractFactory) { _chat = chat; _file = file; baseContent = abstractFactory.GetInstance(); baseContent.NewChatCreated += RemoveFindedUser; }
public ChatClient(RichTextBox textBox) { var channel = GrpcChannel.ForAddress("https://localhost:5001"); this.client = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(channel, this); this.textBox = textBox; }
private async Task InitializeClientAsync() { // Initialize the Hub // NOTE: If you want to use SSL/TLS connection, see InitialSettings.OnRuntimeInitialize method. this.channel = GrpcChannelx.ForAddress("http://localhost:5000"); while (!shutdownCancellation.IsCancellationRequested) { try { Debug.Log($"Connecting to the server..."); this.streamingClient = await StreamingHubClient.ConnectAsync <IChatHub, IChatHubReceiver>(this.channel, this, cancellationToken : shutdownCancellation.Token); this.RegisterDisconnectEvent(streamingClient); Debug.Log($"Connection is established."); break; } catch (Exception e) { Debug.LogError(e); } Debug.Log($"Failed to connect to the server. Retry after 5 seconds..."); await Task.Delay(5 * 1000); } this.client = MagicOnionClient.Create <IChatService>(this.channel); }
public void Start() { this._isJoin = false; var channel = new Channel("localhost:8700", ChannelCredentials.Insecure); this._hub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(channel, this); }
public ContactService(IUnitOfWork uow, IUserService UserService, IHubContext <ChatHub> messageHubContext, IChatHub IChatHub) : base(uow) { _user = uow.Set <User>(); _userimg = uow.Set <UserImg>(); _chat = uow.Set <Chat>(); _UserService = UserService; _messageHubContext = messageHubContext; _IChatHub = IChatHub; }
public ChatVM(IChatHub chat, IFile file, IConference conference) { _chat = chat; _file = file; _conference = conference; _chat.NewCompanionMessage += AddMessage; _chat.MessageDeleted += DeleteMessage; _chat.MessageUpdated += UpdateMessage; }
public ChatController(UserManager <User> _userManager, IMapper _mapper, IContactService _contactService, IBlackListService _blackListService, IChatService _chatService, IHubContext <ChatHub> _hubContext, IChatHub _chatHub) { userManager = _userManager; mapper = _mapper; contactService = _contactService; blackListService = _blackListService; chatService = _chatService; hubContext = _hubContext; chatHub = _chatHub; }
private void InitializeClient() { // Initialize the Hub this.channel = new Channel("localhost", 12345, ChannelCredentials.Insecure); // for SSL/TLS connection //var serverCred = new SslCredentials(File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "server.crt"))); //this.channel = new Channel("test.example.com", 12345, serverCred); this.streamingClient = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(this.channel, this); this.RegisterDisconnectEvent(streamingClient); this.client = MagicOnionClient.Create <IChatService>(this.channel); }
public AccountController(UserManager <User> userManager, SignInManager <User> signInManager, IOptions <EmailConfig> options, IEmailSender emailSender, IMapper mapper, IOptions <ApplicationSettings> appsettings, IChatHub _chatHub, IUserService _userService) { _userManager = userManager; _signInManager = signInManager; _options = options; _emailSender = emailSender; _mapper = mapper; _appsettings = appsettings.Value; chatHub = _chatHub; userService = _userService; }
// Start is called before the first frame update void Start() { this._isJoin = false; //Client側のHubの初期化 this._channel = new Channel("localhost:12345", ChannelCredentials.Insecure); this._chutHub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(this._channel, this); //メッセージ送信ボタンはデフォルト非表示 this.SendMessageButton.gameObject.SetActive(false); }
// Start is called before the first frame update void Start() { this._isJoin = false; //初始化 var channel = new Channel("localhost:12345", ChannelCredentials.Insecure); this._chatHub = StreamingHubClient.Connect <IChatHub, IChat>(channel, this); //默认隐藏发送消息按钮 this.SendMessageButton.gameObject.SetActive(false); }
private void ReconnectServer() { this.streamingClient = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(this.channel, this); this.RegisterDisconnectEvent(streamingClient); Debug.Log("Reconnected server."); this.JoinOrLeaveButton.interactable = true; this.SendMessageButton.interactable = false; this.SendReportButton.interactable = true; this.DisconnectButon.interactable = true; this.isSelfDisConnected = false; }
async void RegisterDisconnect(IChatHub client) { try { // you can wait disconnected event await client.WaitForDisconnect(); } finally { // try-to-reconnect? logging event? etc... Debug.Log("disconnected"); } }
public ChatListVM(IChatHub chat, IAbstractFactory <ChatVM> chatFactory, IFile file) { _chat = chat; _file = file; baseContent = chatFactory.GetInstance(); _chat.ConnectionStarted += GetUserChats; _chat.NewChat += AddChat; _chat.NewCompanionMessage += AddMessage; baseContent.NewMyMessage += AddMessage; _chat.MessageUpdated += UpdateMessage; _chat.MessageDeleted += GetLastMessage; baseContent.RemoveMyMessage += GetLastMessage; }
private async Task InitializeClientAsync() { // If you want configure KEEP_ALIVE interval, then.... // * set same value for `grpc.keepalive_time_ms` and `grpc.http2.min_time_between_pings_ms` // * keep `grpc.http2.min_ping_interval_without_data_ms < grpc.http2.min_time_between_pings_ms` var options = new[] { // send keepalive ping every 10 second, default is 2 hours new ChannelOption("grpc.keepalive_time_ms", 10000), // keepalive ping time out after 5 seconds, default is 20 seoncds new ChannelOption("grpc.keepalive_timeout_ms", 5000), // allow grpc pings from client every 10 seconds new ChannelOption("grpc.http2.min_time_between_pings_ms", 10000), // allow unlimited amount of keepalive pings without data new ChannelOption("grpc.http2.max_pings_without_data", 0), // allow keepalive pings when there's no gRPC calls new ChannelOption("grpc.keepalive_permit_without_calls", 1), // allow grpc pings from client without data every 5 seconds new ChannelOption("grpc.http2.min_ping_interval_without_data_ms", 5000), }; // Initialize the Hub channel = new Channel("localhost", 5000, ChannelCredentials.Insecure, options); // for SSL/TLS connection // var cred = new SslCredentials(File.ReadAllText(Path.Combine(Application.streamingAssetsPath, "server.crt"))); // channel = new Channel("dummy.example.com", 5000, cred, options); // local tls // channel = new Channel("your-nlb-domain.com", 5000, new SslCredentials()); // aws nlb tls while (!shutdownCancellation.IsCancellationRequested) { try { Debug.Log($"Connecting to the server..."); streamingClient = await StreamingHubClient.ConnectAsync <IChatHub, IChatHubReceiver>(channel, this, cancellationToken : shutdownCancellation.Token); RegisterDisconnectEvent(streamingClient); Debug.Log($"Connection is established."); break; } catch (Exception e) { Debug.LogError(e); } Debug.Log($"Failed to connect to the server. Retry after 5 seconds..."); await Task.Delay(5 * 1000); } client = MagicOnionClient.Create <IChatService>(channel); }
// Start is called before the first frame update void Awake() { if (FindObjectsOfType <DataSendServer>().Length > 1) { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); //Client側のHubの初期化 //_channel = new Channel("localhost:12345", ChannelCredentials.Insecure); _channel = new Channel("os3-364-15487.vs.sakura.ne.jp:12345", ChannelCredentials.Insecure); _chatHub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(this._channel, this); firstCheck = true; }
public async void JoinOrCreateRoom() { try { this._chatHub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(MagicOnionManager.Instance.Channel, this); await _chatHub.JoinChat(new JoinOrCreateRoomMesg(LocalPlayer.RoomName, LocalPlayer.PlayerName)); _waitDisConnect(); IsJoin = true; } catch (Exception e) { Debug.LogException(e); } }
private async Task ReconnectServerAsync() { Debug.Log($"Reconnecting to the server..."); this.streamingClient = await StreamingHubClient.ConnectAsync <IChatHub, IChatHubReceiver>(this.channel, this); this.RegisterDisconnectEvent(streamingClient); Debug.Log("Reconnected."); this.JoinOrLeaveButton.interactable = true; this.SendMessageButton.interactable = false; this.SendReportButton.interactable = true; this.DisconnectButon.interactable = true; this.ExceptionButton.interactable = true; this.UnaryExceptionButton.interactable = true; this.isSelfDisConnected = false; }
static void Main(string[] args) { #region DI Container Builder var builder = new ContainerBuilder(); builder.RegisterType <RedisHelper>().As <ICacheHelper>(); builder.RegisterType <ApplicationConfig>().As <IApplicationConfig>(); builder.RegisterType <RabbitMQHelper>().As <IMessageQueueHelper>(); builder.RegisterType <QueueDataModel>().As <IQueueDataModel>(); builder.RegisterType <AgentDataModel>().As <IAgentDataModel>(); builder.RegisterType <ChatHub>().As <IChatHub>(); builder.RegisterType <QueueDataModel>().As <IQueueDataModel>().SingleInstance(); var container = builder.Build(); #endregion using (var scope = container.BeginLifetimeScope()) { #region DI Resolver _cacheHelper = scope.Resolve <ICacheHelper>(); _messageQueueHelper = scope.Resolve <IMessageQueueHelper>(); _applicationConfig = scope.Resolve <IApplicationConfig>(); _queueDataModel = scope.Resolve <IQueueDataModel>(); _agentDataModel = scope.Resolve <IAgentDataModel>(); _chatHub = scope.Resolve <IChatHub>(); var chatMonitorHelper = new ChatMonitorHelper(_queueDataModel, _agentDataModel, _chatHub); var webserverHelper = new WebServerHelper(_applicationConfig); #endregion #region Processors //Start Message Queue Listener Task.Run(() => _messageQueueHelper.ReadMessages <QueueMetaData>(_applicationConfig, chatMonitorHelper.ProcessQueue)); //Start Message Queue Processor Task.Run(() => chatMonitorHelper.MonitorQueue()); //Start WebSocket Server Task.Run(() => webserverHelper.StartWebServer()); #endregion } Console.ReadLine(); }
public void Connect() => chatHub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(VirtualLiveStudioCore.GrpcChannel, this);
public UsersController(IUserManager userManager, IChatHub chatHub, knotSlackDbContext _context) { this.userManager = userManager; this.chatHub = chatHub; this._context = _context; }
public ContactsVM(IChatHub chat) { _chat = chat; _chat.ConnectionStarted += GetUsers; }
void IHubClient.ConnectHub(Channel channel) { _streamingHub = StreamingHubClient.Connect <IChatHub, IChatHubReceiver>(channel, _receiver); }