Skip to content

Commit a6a75ae

Browse files
committedDec 14, 2014
Got 'Play as Guest' working.
1 parent 09af92d commit a6a75ae

File tree

7 files changed

+20
-4
lines changed

7 files changed

+20
-4
lines changed
 

‎Guncho.Core/Api/Hubs/PlayHub.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,14 @@ public PlayHub(ISignalRConnectionManager manager)
2727
public override Task OnConnected()
2828
{
2929
System.Diagnostics.Debug.WriteLine("OnConnected: id = {0}", new string[] { Context.ConnectionId });
30-
manager.NotifyConnectionAccepted(Context.ConnectionId, Context.User.Identity.Name);
30+
31+
string userName = null;
32+
if (Context.User != null && Context.User.Identity != null)
33+
{
34+
userName = Context.User.Identity.Name;
35+
}
36+
37+
manager.NotifyConnectionAccepted(Context.ConnectionId, userName);
3138
return base.OnConnected();
3239
}
3340

‎Guncho.Core/Commands.cs

+1
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,7 @@ private void LogInAsPlayer(Connection conn, Player player)
139139
{
140140
oldConn.WriteLine("*** Connection superseded ***");
141141
conn.WriteLine("*** Connection resumed ***");
142+
conn.FlushOutput();
142143
oldConn.Terminate(wait: true);
143144
}
144145

‎Guncho.Core/Connections/SignalRConnectionManager.cs

+5-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,11 @@ public void NotifyConnectionAccepted(string connectionId, string playerName = nu
7070
{
7171
var connection = new SignalRConnection(this, connectionId);
7272
connections[connectionId] = connection;
73-
ConnectionAccepted(this, new ConnectionAcceptedEventArgs<SignalRConnection>() { Connection = connection, AuthenticatedUserName = playerName });
73+
ConnectionAccepted(this, new ConnectionAcceptedEventArgs<SignalRConnection>()
74+
{
75+
Connection = connection,
76+
AuthenticatedUserName = playerName ?? "Guest"
77+
});
7478
}
7579

7680
public void NotifyConnectionClosed(string connectionId)

‎Guncho.Site/app/services/authService.ts

+1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@
7878

7979
logout(): void {
8080
this.localStorageService.remove('authorizationData');
81+
delete this.signalR.ajaxDefaults.headers.Authorization;
8182

8283
this.authentication.isAuth = false;
8384
this.authentication.userName = "";

‎Guncho.Site/app/services/playService.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,9 @@ module app {
6363

6464
this.proxy.on('goodbye',
6565
() => {
66-
this.stop();
66+
// if we close too soon after receiving the goodbye message, the connection will time out
67+
// instead of closing immediately. 50ms seems to be enough.
68+
$timeout(() => { connection.stop(); }, 50);
6769
});
6870
}
6971

‎Guncho.Site/app/views/listRealms.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ <h1>{{ heading }}</h1>
3131
</tr>
3232
<tr>
3333
<td colspan="4" class="text-center">
34-
<a href="#/newrealm" class="btn btn-sm btn-success">+ Create Realm</a>
34+
<a href="#/newrealm" class="btn btn-sm btn-success"><span class="glyphicon glyphicon-plus"></span> Create Realm</a>
3535
</td>
3636
</tr>
3737
</tbody>

‎RealmData/motd.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*** Welcome, %NAME%! ***

0 commit comments

Comments
 (0)