diff --git a/samples/bidirectional-chat/js/Function/.funcignore b/samples/bidirectional-chat/js/Function/.funcignore new file mode 100644 index 00000000..51792224 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/.funcignore @@ -0,0 +1,7 @@ +*.js.map +*.ts +.git* +.vscode +local.settings.json +test +tsconfig.json \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/.gitignore b/samples/bidirectional-chat/js/Function/.gitignore new file mode 100644 index 00000000..772851c9 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/.gitignore @@ -0,0 +1,94 @@ +# Logs +logs +*.log +npm-debug.log* +yarn-debug.log* +yarn-error.log* +lerna-debug.log* + +# Diagnostic reports (https://nodejs.org/api/report.html) +report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json + +# Runtime data +pids +*.pid +*.seed +*.pid.lock + +# Directory for instrumented libs generated by jscoverage/JSCover +lib-cov + +# Coverage directory used by tools like istanbul +coverage + +# nyc test coverage +.nyc_output + +# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) +.grunt + +# Bower dependency directory (https://bower.io/) +bower_components + +# node-waf configuration +.lock-wscript + +# Compiled binary addons (https://nodejs.org/api/addons.html) +build/Release + +# Dependency directories +node_modules/ +jspm_packages/ + +# TypeScript v1 declaration files +typings/ + +# Optional npm cache directory +.npm + +# Optional eslint cache +.eslintcache + +# Optional REPL history +.node_repl_history + +# Output of 'npm pack' +*.tgz + +# Yarn Integrity file +.yarn-integrity + +# dotenv environment variables file +.env +.env.test + +# parcel-bundler cache (https://parceljs.org/) +.cache + +# next.js build output +.next + +# nuxt.js build output +.nuxt + +# vuepress build output +.vuepress/dist + +# Serverless directories +.serverless/ + +# FuseBox cache +.fusebox/ + +# DynamoDB Local files +.dynamodb/ + +# TypeScript output +dist +out + +# Azure Functions artifacts +bin +obj +appsettings.json +local.settings.json \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/broadcast/function.json b/samples/bidirectional-chat/js/Function/broadcast/function.json new file mode 100644 index 00000000..20cc26a1 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/broadcast/function.json @@ -0,0 +1,22 @@ +{ + "disabled": false, + "bindings": [ + { + "type": "signalRTrigger", + "direction": "in", + "name": "invocation", + "hubName": "simplechat", + "category": "messages", + "event": "broadcast", + "parameterNames": [ + "message" + ] + }, + { + "type": "signalR", + "direction": "out", + "name": "signalRMessages", + "hubName": "simplechat" + } + ] +} diff --git a/samples/bidirectional-chat/js/Function/broadcast/index.js b/samples/bidirectional-chat/js/Function/broadcast/index.js new file mode 100644 index 00000000..879295d1 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/broadcast/index.js @@ -0,0 +1,14 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +module.exports = function (context, invocation) { + context.bindings.signalRMessages = [{ + "target": "newMessage", + "arguments": [{ + "connectionId": invocation.ConnectionId, + "sender": invocation.UserId, + "text": context.bindingData.message + }] + }]; + context.done(); + }; \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/connect/function.json b/samples/bidirectional-chat/js/Function/connect/function.json new file mode 100644 index 00000000..5e44ea76 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/connect/function.json @@ -0,0 +1,18 @@ +{ + "bindings": [ + { + "type": "signalRTrigger", + "direction": "in", + "name": "invocation", + "hubName": "simplechat", + "category": "connections", + "event": "connect" + }, + { + "type": "signalR", + "direction": "out", + "name": "signalRMessages", + "hubName": "simplechat" + } + ] +} diff --git a/samples/bidirectional-chat/js/Function/connect/index.js b/samples/bidirectional-chat/js/Function/connect/index.js new file mode 100644 index 00000000..1cb688d7 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/connect/index.js @@ -0,0 +1,10 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +module.exports = function (context, invocation) { + context.bindings.signalRMessages = [{ + "target": "newConnection", + "arguments": [ { "connectionId": invocation.ConnectionId } ] + }]; + context.done(); + }; \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/extensions.csproj b/samples/bidirectional-chat/js/Function/extensions.csproj new file mode 100644 index 00000000..77c88a15 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/extensions.csproj @@ -0,0 +1,11 @@ + + + netstandard2.0 + + + + + + + + \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/host.json b/samples/bidirectional-chat/js/Function/host.json new file mode 100644 index 00000000..d2059a46 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/host.json @@ -0,0 +1,3 @@ +{ + "version": "2.0" +} diff --git a/samples/bidirectional-chat/js/Function/local.settings.sample.json b/samples/bidirectional-chat/js/Function/local.settings.sample.json new file mode 100644 index 00000000..852dc727 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/local.settings.sample.json @@ -0,0 +1,15 @@ +{ + "IsEncrypted": false, + "Values": { + "AzureWebJobsStorage": "", + "AzureWebJobsDashboard": "", + "FUNCTIONS_WORKER_RUNTIME": "node", + "AzureSignalRConnectionString": "", + "AzureSignalRServiceTransportType": "Transient" + }, + "Host": { + "LocalHttpPort": 7071, + "CORS": "http://localhost:5500", + "CORSCredentials": true + } +} diff --git a/samples/bidirectional-chat/js/Function/negotiate/function.json b/samples/bidirectional-chat/js/Function/negotiate/function.json new file mode 100644 index 00000000..1e088d53 --- /dev/null +++ b/samples/bidirectional-chat/js/Function/negotiate/function.json @@ -0,0 +1,23 @@ +{ + "disabled": false, + "bindings": [ + { + "authLevel": "anonymous", + "type": "httpTrigger", + "direction": "in", + "name": "req" + }, + { + "type": "http", + "direction": "out", + "name": "res" + }, + { + "type": "signalRConnectionInfo", + "name": "connectionInfo", + "userId": "{headers.x-ms-signalr-userid}", + "hubName": "simplechat", + "direction": "in" + } + ] +} diff --git a/samples/bidirectional-chat/js/Function/negotiate/index.js b/samples/bidirectional-chat/js/Function/negotiate/index.js new file mode 100644 index 00000000..d6868e9d --- /dev/null +++ b/samples/bidirectional-chat/js/Function/negotiate/index.js @@ -0,0 +1,7 @@ +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. + +module.exports = function (context, req, connectionInfo) { + context.res = { body: connectionInfo }; + context.done(); + }; \ No newline at end of file diff --git a/samples/bidirectional-chat/js/Function/package-lock.json b/samples/bidirectional-chat/js/Function/package-lock.json new file mode 100644 index 00000000..dfca5b0d --- /dev/null +++ b/samples/bidirectional-chat/js/Function/package-lock.json @@ -0,0 +1,5 @@ +{ + "name": "js", + "version": "1.0.0", + "lockfileVersion": 1 +} diff --git a/samples/bidirectional-chat/js/Function/package.json b/samples/bidirectional-chat/js/Function/package.json new file mode 100644 index 00000000..bb543b3c --- /dev/null +++ b/samples/bidirectional-chat/js/Function/package.json @@ -0,0 +1,11 @@ +{ + "name": "js", + "version": "1.0.0", + "description": "", + "scripts": { + "start": "func start", + "test": "echo \"No tests yet...\"" + }, + "dependencies": {}, + "devDependencies": {} +} diff --git a/samples/bidirectional-chat/js/Function/proxies.json b/samples/bidirectional-chat/js/Function/proxies.json new file mode 100644 index 00000000..b385252f --- /dev/null +++ b/samples/bidirectional-chat/js/Function/proxies.json @@ -0,0 +1,4 @@ +{ + "$schema": "http://json.schemastore.org/proxies", + "proxies": {} +}