Skip to content

Commit 85acffc

Browse files
committed
入室時にサーバー接続処理するように修正
1 parent 0180c99 commit 85acffc

File tree

1 file changed

+8
-13
lines changed
  • KumattaApp-Client/Assets/KumattaApp/Scripts/ChatApp

1 file changed

+8
-13
lines changed

KumattaApp-Client/Assets/KumattaApp/Scripts/ChatApp/ChatApp.cs

+8-13
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ public class ChatApp : MonoBehaviour, IChatAppHubReceiver
7070
/// </summary>
7171
private string userName = "名無し";
7272

73+
7374
private void Start()
7475
{
7576
// 画面を非表示
@@ -92,7 +93,8 @@ private void Start()
9293
var sendButton = chatPage.GetComponentInChildren<Button>(true);
9394
sendButton.onClick.AddListener(OnClick_SendButton);
9495

95-
Init();
96+
// 入室画面を表示
97+
joinPage.SetActive(true);
9698
}
9799

98100
private async void OnDestroy()
@@ -116,6 +118,10 @@ private async void OnClick_JoinButton()
116118
userName = nameInput.text;
117119
}
118120

121+
// サーバーへ接続
122+
channel = GrpcChannelx.ForAddress("http://192.168.179.4:5001");
123+
streamingClient = await StreamingHubClient.ConnectAsync<IChatAppHub, IChatAppHubReceiver>(channel, this, cancellationToken: shutdownCancellation.Token);
124+
119125
await streamingClient.JoinAsync(roomName, userName);
120126
joinPage.SetActive(false);
121127
chatPage.SetActive(true);
@@ -131,17 +137,6 @@ private async void OnClick_SendButton()
131137
}
132138
#endregion
133139

134-
/// <summary>
135-
/// 初期処理
136-
/// </summary>
137-
private async void Init()
138-
{
139-
// サーバーへ接続
140-
channel = GrpcChannelx.ForAddress("http://localhost:5001");
141-
streamingClient = await StreamingHubClient.ConnectAsync<IChatAppHub, IChatAppHubReceiver>(channel, this, cancellationToken: shutdownCancellation.Token);
142-
joinPage.SetActive(true);
143-
}
144-
145140

146141
#region MagicOnion サーバー⇒クライアントの受信
147142

@@ -174,4 +169,4 @@ public void OnSendMessage(string userName, string message)
174169
}
175170
#endregion
176171
}
177-
}
172+
}

0 commit comments

Comments
 (0)