Skip to content

Commit cd04f4c

Browse files
author
lith
committed
auto commit 1.0.0
0 parents  commit cd04f4c

34 files changed

Lines changed: 1467 additions & 0 deletions

.github/workflows/action-main.yml

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# This is a basic workflow to help you get started with Actions
2+
3+
name: CI
4+
5+
# Controls when the action will run.
6+
on:
7+
8+
push:
9+
# Triggers the workflow on push events but only for the master branch
10+
#branches: [ master ]
11+
12+
# Triggers the workflow on push tag
13+
tags: ['*']
14+
15+
# Allows you to run this workflow manually from the Actions tab
16+
workflow_dispatch:
17+
18+
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
19+
jobs:
20+
# This workflow contains a single job called "build"
21+
build:
22+
# The type of runner that the job will run on
23+
runs-on: ubuntu-latest
24+
25+
# Steps represent a sequence of tasks that will be executed as part of the job
26+
steps:
27+
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
28+
- uses: actions/checkout@v2
29+
30+
# Runs a set of commands using the runners shell
31+
- name: Run startup.bash
32+
run: |
33+
set -e
34+
echo start build
35+
export NUGET_SERVER="${{ secrets.NUGET_SERVER }}"
36+
export NUGET_KEY="${{ secrets.NUGET_KEY }}"
37+
export GIT_SSH_SECRET="${{ secrets.GIT_SSH_SECRET }}"
38+
cd ./Publish/DevOps/github-bash
39+
bash startup.bash
40+
echo build succeed!
41+
42+
echo "appName=Vit.AspNetCore.WebSocket" >> $GITHUB_ENV
43+
44+
45+
- name: release_create
46+
id: release_create
47+
uses: actions/create-release@v1
48+
#if: hashFiles(env.release_assetPath)
49+
env:
50+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
51+
with:
52+
release_name: ${{ env.release_name }}
53+
tag_name: ${{ env.release_tag }}
54+
draft: ${{ env.release_draft }}
55+
prerelease: ${{ env.release_prerelease }}
56+
body: ${{ env.release_body }}
57+
58+
59+
# release_upload_asset
60+
61+
- uses: actions/upload-release-asset@v1
62+
env:
63+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64+
with:
65+
upload_url: ${{ steps.release_create.outputs.upload_url }}
66+
asset_path: ${{ env.release_dirPath }}/${{ env.appName }}-nuget-${{ env.release_version }}.zip
67+
asset_name: ${{ env.appName }}-nuget-${{ env.release_version }}.zip
68+
asset_content_type: application/zip
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
using System;
2+
3+
namespace Vit.AspNetCore.TaskProcess.Demo
4+
{
5+
public class WeatherForecast
6+
{
7+
public DateTime Date { get; set; }
8+
9+
public int TemperatureC { get; set; }
10+
11+
public int TemperatureF => 32 + (int)(TemperatureC / 0.5556);
12+
13+
public string Summary { get; set; }
14+
}
15+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using Microsoft.Extensions.Logging;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Threading.Tasks;
7+
8+
namespace Vit.AspNetCore.TaskProcess.Demo.Controllers
9+
{
10+
[ApiController]
11+
[Route("[controller]")]
12+
public class WeatherForecastController : ControllerBase
13+
{
14+
private static readonly string[] Summaries = new[]
15+
{
16+
"Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching"
17+
};
18+
19+
private readonly ILogger<WeatherForecastController> _logger;
20+
21+
public WeatherForecastController(ILogger<WeatherForecastController> logger)
22+
{
23+
_logger = logger;
24+
}
25+
26+
[HttpGet]
27+
public IEnumerable<WeatherForecast> Get()
28+
{
29+
var rng = new Random();
30+
return Enumerable.Range(1, 5).Select(index => new WeatherForecast
31+
{
32+
Date = DateTime.Now.AddDays(index),
33+
TemperatureC = rng.Next(-20, 55),
34+
Summary = Summaries[rng.Next(Summaries.Length)]
35+
})
36+
.ToArray();
37+
}
38+
}
39+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
using System.Threading.Tasks;
3+
4+
namespace App.Controller
5+
{
6+
[Route("/websocket")]
7+
public class WebSocketController: Vit.AspNetCore.WebSocket.WebSocketController
8+
{
9+
public override async Task OnGetTextAsync(string text)
10+
{
11+
await SendTextAsync(text);
12+
}
13+
}
14+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
using Microsoft.AspNetCore;
2+
using Microsoft.AspNetCore.Hosting;
3+
using Vit.Extensions;
4+
5+
namespace App
6+
{
7+
public class Program
8+
{
9+
public static void Main(string[] args)
10+
{
11+
CreateWebHostBuilder(args).Build().Run();
12+
}
13+
14+
15+
public static IWebHostBuilder CreateWebHostBuilder(string[] args) =>
16+
WebHost.CreateDefaultBuilder(args)
17+
.UseWebSocketController() //ÆôÓÃWebSocket
18+
.UseStartup<Startup>();
19+
}
20+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
{
2+
"$schema": "http://json.schemastore.org/launchsettings.json",
3+
"iisSettings": {
4+
"windowsAuthentication": false,
5+
"anonymousAuthentication": true
6+
},
7+
"profiles": {
8+
"WSL": {
9+
"commandName": "WSL2",
10+
"launchBrowser": true,
11+
"launchUrl": "http://localhost:5000/index.html",
12+
"environmentVariables": {
13+
"ASPNETCORE_ENVIRONMENT": "Development",
14+
"ASPNETCORE_URLS": "http://localhost:5000"
15+
},
16+
"distributionName": ""
17+
},
18+
"Web": {
19+
"commandName": "Project",
20+
"launchBrowser": true,
21+
"launchUrl": "index.html",
22+
"environmentVariables": {
23+
"ASPNETCORE_ENVIRONMENT": "Development"
24+
},
25+
"applicationUrl": "http://localhost:5000"
26+
}
27+
}
28+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
using Microsoft.AspNetCore.Builder;
3+
using Microsoft.AspNetCore.Hosting;
4+
using Microsoft.AspNetCore.Mvc;
5+
using Microsoft.Extensions.Configuration;
6+
using Microsoft.Extensions.DependencyInjection;
7+
8+
namespace App
9+
{
10+
public class Startup
11+
{
12+
public Startup(IConfiguration configuration)
13+
{
14+
Configuration = configuration;
15+
}
16+
17+
18+
public IConfiguration Configuration { get; }
19+
20+
// This method gets called by the runtime. Use this method to add services to the container.
21+
public void ConfigureServices(IServiceCollection services)
22+
{
23+
services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);
24+
}
25+
26+
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
27+
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
28+
{
29+
30+
if (env.IsDevelopment())
31+
{
32+
app.UseDeveloperExceptionPage();
33+
}
34+
else
35+
{
36+
app.UseHsts();
37+
}
38+
39+
app.UseStaticFiles();
40+
41+
app.UseMvc();
42+
app.UseMvcWithDefaultRoute();
43+
44+
}
45+
46+
}
47+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp2.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.AspNetCore.App" />
9+
10+
</ItemGroup>
11+
12+
<ItemGroup>
13+
<ProjectReference Include="..\..\Vit.AspNetCore.WebSocket\Vit.AspNetCore.WebSocket.csproj" />
14+
</ItemGroup>
15+
16+
17+
</Project>
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"Logging": {
3+
"LogLevel": {
4+
"Default": "Information",
5+
"Microsoft": "Warning",
6+
"Microsoft.Hosting.Lifetime": "Information"
7+
}
8+
},
9+
"AllowedHosts": "*"
10+
}
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+

2+
; (() => {
3+
4+
5+
var webSocket;
6+
var host = "ws://" + location.host + "/websocket";
7+
var isOpen = false;
8+
9+
function log(msg) {
10+
console.log(msg);
11+
txt.value += msg + '\r\n';
12+
}
13+
14+
15+
//创建websockt
16+
function CreateWebSocket() {
17+
webSocket = new WebSocket(host);
18+
webSocket.onopen = WebSokectOnOpen;
19+
webSocket.onmessage = WebSocketOnMessage;
20+
webSocket.onclose = WebSocketOnClose;
21+
}
22+
23+
CreateWebSocket();
24+
setInterval(function () {
25+
if (isOpen) {
26+
var msg = '' + Math.random();
27+
log('websocket send:' + msg);
28+
webSocket.send(msg);
29+
}
30+
}, 500);
31+
32+
function WebSokectOnOpen() {
33+
isOpen = true;
34+
log('websocket OnOpen');
35+
}
36+
37+
38+
function WebSocketOnMessage(event) {
39+
40+
try {
41+
var msg = '' + event.data;
42+
log('websocket OnMessage:' + msg);
43+
} catch (e) {
44+
}
45+
}
46+
47+
function WebSocketOnClose() {
48+
isOpen = false;
49+
log('websocket OnClose');
50+
CreateWebSocket();
51+
}
52+
53+
54+
55+
})();

0 commit comments

Comments
 (0)