FastTunnel/FastTunnel.Core/Extensions/SocketExtensions.cs

25 lines
735 B
C#
Raw Normal View History

2022-01-02 00:23:39 +08:00
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// You may obtain a copy of the License at
// https://github.com/FastTunnel/FastTunnel/edit/v2/LICENSE
// Copyright (c) 2019 Gui.H
using FastTunnel.Core.Models;
2022-06-29 15:48:53 +08:00
using FastTunnel.Core.Models.Massage;
2019-12-16 10:29:06 +08:00
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
namespace FastTunnel.Core.Extensions
{
2021-08-02 00:04:13 +08:00
public static class SocketExtensions
2019-12-16 10:29:06 +08:00
{
2021-06-19 14:26:57 +08:00
public static void SendCmd<T>(this Socket socket, Message<T> message)
where T : TunnelMassage
2019-12-16 10:29:06 +08:00
{
2021-06-21 22:28:34 +08:00
socket.Send(Encoding.UTF8.GetBytes(message.ToJson() + "\n"));
2019-12-16 10:29:06 +08:00
}
}
}