Fix BidirectionChat samples (#226)
1. Added `local.settings.json` file to dotnet isolated-worker sample 2. Fixed the UI problem that "AddUserToGroup", "RemoveUserFromGroup" buttons appear in the messages whose user ID is null.
This commit is contained in:
Родитель
2e928b19f5
Коммит
c255794db2
|
@ -33,7 +33,8 @@
|
|||
<label for="checkbox">Send To Default Group: {{ this.defaultgroup }}</label>
|
||||
</div>
|
||||
<form v-on:submit.prevent="sendNewMessage(checked)">
|
||||
<input type="text" v-model="newMessage" id="message-box" class="form-control" placeholder="Type message here..." />
|
||||
<input type="text" v-model="newMessage" id="message-box" class="form-control"
|
||||
placeholder="Type message here..." />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -57,20 +58,25 @@
|
|||
</a>
|
||||
<span v-if="message.ConnectionId || message.connectionId">
|
||||
<a href="#" v-on:click.prevent="sendToConnection(message.ConnectionId || message.connectionId)">
|
||||
<span class="badge badge-primary">Connection: {{ message.ConnectionId || message.connectionId }}</span>
|
||||
<span class="badge badge-primary">Connection: {{ message.ConnectionId ||
|
||||
message.connectionId
|
||||
}}</span>
|
||||
</a>
|
||||
</span>
|
||||
<a href="#" v-on:click.prevent="addUserToGroup(message.Sender || message.sender)">
|
||||
<span class="badge badge-primary">AddUserToGroup</span>
|
||||
<span v-if="message.Sender || message.sender" class="badge badge-primary">AddUserToGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="removeUserFromGroup(message.Sender || message.sender)">
|
||||
<span class="badge badge-primary">RemoveUserFromGroup</span>
|
||||
<span v-if="message.Sender || message.sender" class="badge badge-primary">RemoveUserFromGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="addConnectionToGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId" class="badge badge-primary">AddConnectionToGroup</span>
|
||||
<span v-if="message.ConnectionId || message.connectionId"
|
||||
class="badge badge-primary">AddConnectionToGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="removeConnectionIdFromGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId" class="badge badge-primary">RemoveConnectionFromGroup</span>
|
||||
<a href="#"
|
||||
v-on:click.prevent="removeConnectionIdFromGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId"
|
||||
class="badge badge-primary">RemoveConnectionFromGroup</span>
|
||||
</a>
|
||||
<span v-if="message.IsPrivate || message.isPrivate" class="badge badge-secondary">private message
|
||||
</span>
|
||||
|
@ -187,8 +193,7 @@
|
|||
function onNewConnection(message) {
|
||||
data.myConnectionId = message.ConnectionId;
|
||||
authEnabled = false;
|
||||
if (message.Authentication)
|
||||
{
|
||||
if (message.Authentication) {
|
||||
authEnabled = true;
|
||||
}
|
||||
newConnectionMessage = {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AzureFunctionsVersion>v3</AzureFunctionsVersion>
|
||||
<AzureFunctionsVersion>v4</AzureFunctionsVersion>
|
||||
<RootNamespace>bidirectional_chat</RootNamespace>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
|
|
|
@ -28,7 +28,7 @@ namespace IsolatedModel_BidirectionChat
|
|||
public SignalRConnectionInfo Negotiate([HttpTrigger(AuthorizationLevel.Anonymous)] HttpRequestData req,
|
||||
[SignalRConnectionInfoInput(HubName = "Hub", UserId = "{query.userid}")] SignalRConnectionInfo signalRConnectionInfo)
|
||||
{
|
||||
_logger.LogInformation("Executing negotation.");
|
||||
_logger.LogInformation("Executing negotiation.");
|
||||
return signalRConnectionInfo;
|
||||
}
|
||||
|
||||
|
@ -47,18 +47,11 @@ namespace IsolatedModel_BidirectionChat
|
|||
|
||||
[Function("Broadcast")]
|
||||
[SignalROutput(HubName = "Hub")]
|
||||
public SignalRMessageAction Broadcast(
|
||||
[SignalREndpointsInput("Hub")] SignalREndpoint[] endpoints,
|
||||
[SignalRNegotiationInput("Hub", "AzureSignalRConnectionString")] SignalRNegotiationContext negotiationContext,
|
||||
[SignalRTrigger("Hub", "messages", "Broadcast", "message")] SignalRInvocationContext invocationContext, string message)
|
||||
public SignalRMessageAction Broadcast([SignalRTrigger("Hub", "messages", "Broadcast", "message")] SignalRInvocationContext invocationContext, string message)
|
||||
{
|
||||
_logger.LogInformation($"{negotiationContext.Endpoints[0].Endpoint}");
|
||||
_logger.LogInformation($"{negotiationContext.Endpoints[0].ConnectionInfo.AccessToken}");
|
||||
_logger.LogInformation($"{negotiationContext.Endpoints[1].Endpoint}");
|
||||
return new SignalRMessageAction("newMessage")
|
||||
{
|
||||
Arguments = new object[] { new NewMessage(invocationContext, message) },
|
||||
Endpoints = endpoints
|
||||
Arguments = new object[] { new NewMessage(invocationContext, message) }
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
<label for="checkbox">Send To Default Group: {{ this.defaultgroup }}</label>
|
||||
</div>
|
||||
<form v-on:submit.prevent="sendNewMessage(checked)">
|
||||
<input type="text" v-model="newMessage" id="message-box" class="form-control" placeholder="Type message here..." />
|
||||
<input type="text" v-model="newMessage" id="message-box" class="form-control"
|
||||
placeholder="Type message here..." />
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -56,21 +57,30 @@
|
|||
</span>
|
||||
</a>
|
||||
<span v-if="message.ConnectionId || message.connectionId">
|
||||
<a href="#" v-on:click.prevent="sendToConnection(message.ConnectionId || message.connectionId)">
|
||||
<span class="badge badge-primary">Connection: {{ message.ConnectionId || message.connectionId }}</span>
|
||||
<a href="#"
|
||||
v-on:click.prevent="sendToConnection(message.ConnectionId || message.connectionId)">
|
||||
<span class="badge badge-primary">Connection: {{ message.ConnectionId ||
|
||||
message.connectionId }}</span>
|
||||
</a>
|
||||
</span>
|
||||
<a href="#" v-on:click.prevent="addUserToGroup(message.Sender || message.sender)">
|
||||
<span class="badge badge-primary">AddUserToGroup</span>
|
||||
<span v-if="message.Sender || message.sender"
|
||||
class="badge badge-primary">AddUserToGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="removeUserFromGroup(message.Sender || message.sender)">
|
||||
<span class="badge badge-primary">RemoveUserFromGroup</span>
|
||||
<a href="#"
|
||||
v-on:click.prevent="removeUserFromGroup(message.Sender || message.sender)">
|
||||
<span v-if="message.Sender || message.sender"
|
||||
class="badge badge-primary">RemoveUserFromGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="addConnectionToGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId" class="badge badge-primary">AddConnectionToGroup</span>
|
||||
<a href="#"
|
||||
v-on:click.prevent="addConnectionToGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId"
|
||||
class="badge badge-primary">AddConnectionToGroup</span>
|
||||
</a>
|
||||
<a href="#" v-on:click.prevent="removeConnectionIdFromGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId" class="badge badge-primary">RemoveConnectionFromGroup</span>
|
||||
<a href="#"
|
||||
v-on:click.prevent="removeConnectionIdFromGroup(message.ConnectionId || message.connectionId)">
|
||||
<span v-if="message.ConnectionId || message.connectionId"
|
||||
class="badge badge-primary">RemoveConnectionFromGroup</span>
|
||||
</a>
|
||||
<span v-if="message.IsPrivate || message.isPrivate" class="badge badge-secondary">
|
||||
private message
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
{
|
||||
"IsEncrypted": false,
|
||||
"Values": {
|
||||
"AzureWebJobsStorage": "UseDevelopmentStorage=true",
|
||||
"FUNCTIONS_WORKER_RUNTIME": "dotnet-isolated",
|
||||
"AzureSignalRConnectionString": ""
|
||||
}
|
||||
}
|
Загрузка…
Ссылка в новой задаче