public async Task <GameObject> ConnectAsync(Channel grpcChannel, string roomName, string playerName) { client = StreamingHubClient.Connect <IGamingHub, IGamingHubReceiver>(grpcChannel, this); var roomPlayers = await client.JoinAsync(roomName, playerName, Vector3.zero, Quaternion.identity); foreach (var player in roomPlayers) { (this as IGamingHubReceiver).OnJoin(player); } return(players[playerName]); }
public async Task <string> ConnectAsync(Channel grpcChannel, string roomName, string playerName) { client = StreamingHubClient.Connect <IGamingHub, IGamingHubReceiver>(grpcChannel, this); var roomPlayers = await client.JoinAsync(roomName, playerName, 0d, 0d); foreach (var player in roomPlayers) { (this as IGamingHubReceiver).OnJoin(player); } return(playerName); }
public async Task <GameObject> ConnectAsync(Channel grpcChannel, string roomName, string playerName) { Debug.Log("aaaa"); this.gamingHub = await StreamingHubClient.ConnectAsync <IGamingHub, IGamingHubReceiver>(grpcChannel, this); // var roomPlayers = await gamingHub.JoinAsync(roomName, playerName, Vector3.zero, Quaternion.identity); foreach (var player in roomPlayers) { if (player.Name != playerName) { (this as IGamingHubReceiver).OnJoin(player); } } return(players[playerName]); }
public async Task JoinRoom(string hostName, string userName) { try { channel = new Channel($"{hostName}:12345", ChannelCredentials.Insecure, new[] { new ChannelOption(ChannelOptions.MaxReceiveMessageLength, int.MaxValue), new ChannelOption(ChannelOptions.MaxSendMessageLength, int.MaxValue), }); hub = await receiver.ConnectAsync(channel); selfID = await hub.JoinRoomAsync(userName); Notification.Notify("ルームに入室しました"); } catch (Exception e) { Notification.Notify("ルーム入室に失敗しました"); Debug.LogError(e); throw; } }
public async ValueTask RunAsync(CancellationToken cancellationToken = default) { var capabilitis = new List <string>(); var interfaces = typeof(T).GetInterfaces().Select(type => type.FullName).ToHashSet(); if (interfaces.Contains(typeof(ImportPlugin).FullName)) { capabilitis.Add(typeof(ImportPlugin).FullName); } var capability = new Capability { Capabilities = capabilitis }; var grpcChannel = GrpcChannel.ForAddress(address); client = await StreamingHubClient.ConnectAsync <IGamingHub, IGamingHubReceiver>(grpcChannel, this); instanceId = await client.RegisterPlugin(capability); await Task.Delay(TimeSpan.FromMilliseconds(-1), cancellationToken); }
// 指定したルームに入室するための関数 // StreamingHubClient で使用する gRPC チャネル及び、参加したい部屋名、使用するユーザ名を引数に指定する public async Task <GameObject> ConnectAsync(Channel grpcChannel, string roomName, string playerName) { // サーバ側の関数を実行するための StreamingHubClient を生成する _client = StreamingHubClient.Connect <IGamingHub, IGamingHubReceiver>(grpcChannel, this); // JoinAsync 関数を実行して部屋に入室すると同時に、 // 既に入室済みのユーザ全員の情報を配列で取得する var roomPlayers = await _client.JoinAsync(roomName, playerName, Vector3.zero, Quaternion.identity); // 自ユーザ以外を OnJoin 関数に渡して、 // this.players に部屋の他ユーザ全員の情報をセットする // 自ユーザの情報は await で JoinAsync を実行した段階で、 // OnJoin がコールバックで呼ばれているためセット済みの状態となっている foreach (var player in roomPlayers) { if (player.Name != playerName) { (this as IGamingHubReceiver).OnJoin(player); } } // 自ユーザの情報を返却する return(_players[playerName]); }