mirror of
https://github.com/FastTunnel/FastTunnel.git
synced 2025-02-08 02:39:29 +08:00
fixbug
This commit is contained in:
parent
fb90899067
commit
7296514d6c
27
FastTunel.Core.WebApi/Properties/launchSettings.json
Normal file
27
FastTunel.Core.WebApi/Properties/launchSettings.json
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"iisSettings": {
|
||||
"windowsAuthentication": false,
|
||||
"anonymousAuthentication": true,
|
||||
"iisExpress": {
|
||||
"applicationUrl": "http://localhost:55100/",
|
||||
"sslPort": 44347
|
||||
}
|
||||
},
|
||||
"profiles": {
|
||||
"IIS Express": {
|
||||
"commandName": "IISExpress",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
}
|
||||
},
|
||||
"FastTunel.Core.WebApi": {
|
||||
"commandName": "Project",
|
||||
"launchBrowser": true,
|
||||
"environmentVariables": {
|
||||
"ASPNETCORE_ENVIRONMENT": "Development"
|
||||
},
|
||||
"applicationUrl": "https://localhost:5001;http://localhost:5000"
|
||||
}
|
||||
}
|
||||
}
|
|
@ -65,9 +65,27 @@ namespace FastTunnel.Core.Listener
|
|||
return false;
|
||||
}
|
||||
|
||||
IClientMessageHandler handler = null;
|
||||
try
|
||||
{
|
||||
msg = JsonConvert.DeserializeObject<Message<JObject>>(words);
|
||||
//if (msg == null)
|
||||
// throw new Exception("指令为空!");
|
||||
|
||||
switch (msg.MessageType)
|
||||
{
|
||||
case MessageType.C_LogIn: // 登录
|
||||
handler = _loginHandler;
|
||||
break;
|
||||
case MessageType.Heart: // 心跳
|
||||
handler = _heartHandler;
|
||||
break;
|
||||
case MessageType.C_SwapMsg: // 交换数据
|
||||
handler = _swapMsgHandler;
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"未知的通讯指令 {msg.MessageType}");
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
@ -76,22 +94,6 @@ namespace FastTunnel.Core.Listener
|
|||
return false;
|
||||
}
|
||||
|
||||
IClientMessageHandler handler = null;
|
||||
switch (msg.MessageType)
|
||||
{
|
||||
case MessageType.C_LogIn: // 登录
|
||||
handler = _loginHandler;
|
||||
break;
|
||||
case MessageType.Heart: // 心跳
|
||||
handler = _heartHandler;
|
||||
break;
|
||||
case MessageType.C_SwapMsg: // 交换数据
|
||||
handler = _swapMsgHandler;
|
||||
break;
|
||||
default:
|
||||
throw new Exception($"未知的通讯指令 {msg.MessageType}");
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
handler.HandlerMsg(this._fastTunnelServer, token.Socket, msg);
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
using FastTunnel.Core.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Sockets;
|
||||
|
@ -11,7 +12,14 @@ namespace FastTunnel.Core.Extensions
|
|||
public static void SendCmd<T>(this Socket socket, Message<T> message)
|
||||
where T : TunnelMassage
|
||||
{
|
||||
socket.Send(Encoding.UTF8.GetBytes(message.ToJson() + "\n"));
|
||||
if (socket.Connected)
|
||||
{
|
||||
socket.Send(Encoding.UTF8.GetBytes(message.ToJson() + "\n"));
|
||||
}
|
||||
else
|
||||
{
|
||||
Console.WriteLine($"连接中断,消息发送失败:【{message.Content}】");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user