tanghai 12 anni fa
parent
commit
e76b8dc8c8

+ 0 - 96
CSharp/App/BossMonit/BossMonit.cs

@@ -1,96 +0,0 @@
-
-using System;
-using System.Diagnostics;
-using System.IO;
-using System.Net.Sockets;
-using System.Runtime.InteropServices;
-using ProtoBuf;
-
-// 这个库要用到protobuf-net库,用Nuget安装即可
-
-namespace BossMonit
-{
-	static class InternalApi
-	{
-		[DllImport("internal.dll")]
-		public static extern ulong hash_string(string data, int size);
-	};
-
-	public static class ProtobufHelper
-	{
-		public static byte[] ToBytes<T>(T message)
-		{
-			var ms = new MemoryStream();
-			Serializer.Serialize(ms, message);
-			return ms.ToArray();
-		}
-
-		public static T FromBytes<T>(byte[] bytes)
-		{
-			var ms = new MemoryStream(bytes, 0, bytes.Length);
-			return Serializer.Deserialize<T>(ms);
-		}
-
-		public static T FromBytes<T>(byte[] bytes, int index, int length)
-		{
-			var ms = new MemoryStream(bytes, index, length);
-			return Serializer.Deserialize<T>(ms);
-		}
-	}
-
-	public class BossMonit: IDisposable
-	{
-		private readonly TcpClient tcpClient;
-
-		public BossMonit(string host, ushort port)
-		{
-			this.tcpClient = new TcpClient();
-			this.tcpClient.Connect(host, port);
-		}
-
-		public GmResult GmControl(GmRequest request)
-		{
-			var stream = tcpClient.GetStream();
-
-			// 发送
-			// magic_num
-			stream.WriteByte(0xAA);
-
-			// call_guid, 同步调用这个字段随意设置
-			var bytes = BitConverter.GetBytes((ulong) 0);
-			stream.Write(bytes, 0, bytes.Length);
-
-			// method_id
-			const string method_full_name = "boss.GmControl";
-			ulong method_id = InternalApi.hash_string(method_full_name, method_full_name.Length);
-			bytes = BitConverter.GetBytes(method_id);
-
-			var requestBytes = ProtobufHelper.ToBytes(request);
-
-			// size
-			bytes = BitConverter.GetBytes(requestBytes.Length);
-			stream.Write(bytes, 0, bytes.Length);
-
-			// request content
-			stream.Write(requestBytes, 0, requestBytes.Length);
-
-			// 接收
-			var recvBuffer = new byte[21];
-			stream.Read(recvBuffer, 0, recvBuffer.Length);
-
-			Debug.Assert(recvBuffer[0] == 0xAA);
-			uint return_size = BitConverter.ToUInt32(recvBuffer, 1 + 8 + 8);
-
-			recvBuffer = new byte[return_size];
-			stream.Read(recvBuffer, 0, recvBuffer.Length);
-
-			var response = ProtobufHelper.FromBytes<GmResult>(recvBuffer);
-			return response;
-		}
-
-		public void Dispose()
-		{
-			tcpClient.Close();
-		}
-	}
-}

+ 0 - 61
CSharp/App/BossMonit/BossMonit.csproj

@@ -1,61 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
-  <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
-  <PropertyGroup>
-    <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
-    <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
-    <ProjectGuid>{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}</ProjectGuid>
-    <OutputType>Library</OutputType>
-    <AppDesignerFolder>Properties</AppDesignerFolder>
-    <RootNamespace>BossMonit</RootNamespace>
-    <AssemblyName>BossMonit</AssemblyName>
-    <TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
-    <FileAlignment>512</FileAlignment>
-    <SolutionDir Condition="$(SolutionDir) == '' Or $(SolutionDir) == '*Undefined*'">..\..\</SolutionDir>
-    <RestorePackages>true</RestorePackages>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
-    <DebugSymbols>true</DebugSymbols>
-    <DebugType>full</DebugType>
-    <Optimize>false</Optimize>
-    <OutputPath>..\..\Bin\</OutputPath>
-    <DefineConstants>DEBUG;TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
-    <DebugType>pdbonly</DebugType>
-    <Optimize>true</Optimize>
-    <OutputPath>bin\Release\</OutputPath>
-    <DefineConstants>TRACE</DefineConstants>
-    <ErrorReport>prompt</ErrorReport>
-    <WarningLevel>4</WarningLevel>
-  </PropertyGroup>
-  <ItemGroup>
-    <Reference Include="protobuf-net, Version=2.0.0.640, Culture=neutral, PublicKeyToken=257b51d87d2e4d67, processorArchitecture=MSIL">
-      <SpecificVersion>False</SpecificVersion>
-      <HintPath>..\..\packages\protobuf-net.2.0.0.640\lib\net40\protobuf-net.dll</HintPath>
-    </Reference>
-    <Reference Include="System" />
-    <Reference Include="System.Core" />
-    <Reference Include="System.Runtime.Serialization" />
-    <Reference Include="System.Xml" />
-  </ItemGroup>
-  <ItemGroup>
-    <Compile Include="BossMonit.cs" />
-    <Compile Include="Properties\AssemblyInfo.cs" />
-    <Compile Include="Protocol.cs" />
-  </ItemGroup>
-  <ItemGroup>
-    <None Include="Packages.config" />
-  </ItemGroup>
-  <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
-  <Import Project="$(SolutionDir)\.nuget\NuGet.targets" Condition="Exists('$(SolutionDir)\.nuget\NuGet.targets')" />
-  <!-- To modify your build process, add your task inside one of the targets below and uncomment it. 
-       Other similar extension points exist, see Microsoft.Common.targets.
-  <Target Name="BeforeBuild">
-  </Target>
-  <Target Name="AfterBuild">
-  </Target>
-  -->
-</Project>

+ 0 - 4
CSharp/App/BossMonit/Packages.config

@@ -1,4 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<packages>
-  <package id="protobuf-net" version="2.0.0.640" targetFramework="net45" />
-</packages>

+ 0 - 36
CSharp/App/BossMonit/Properties/AssemblyInfo.cs

@@ -1,36 +0,0 @@
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-
-// 有关程序集的常规信息通过以下
-// 特性集控制。更改这些特性值可修改
-// 与程序集关联的信息。
-[assembly: AssemblyTitle("BossMonit")]
-[assembly: AssemblyDescription("")]
-[assembly: AssemblyConfiguration("")]
-[assembly: AssemblyCompany("")]
-[assembly: AssemblyProduct("BossMonit")]
-[assembly: AssemblyCopyright("Copyright ©  2013")]
-[assembly: AssemblyTrademark("")]
-[assembly: AssemblyCulture("")]
-
-// 将 ComVisible 设置为 false 使此程序集中的类型
-// 对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型,
-// 则将该类型上的 ComVisible 特性设置为 true。
-[assembly: ComVisible(false)]
-
-// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
-[assembly: Guid("8c6d59b7-1d93-4d10-bf66-fc8bc0af2adb")]
-
-// 程序集的版本信息由下面四个值组成:
-//
-//      主版本
-//      次版本 
-//      生成号
-//      修订号
-//
-// 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
-// 方法是按如下所示使用“*”:
-// [assembly: AssemblyVersion("1.0.*")]
-[assembly: AssemblyVersion("1.0.0.0")]
-[assembly: AssemblyFileVersion("1.0.0.0")]

+ 0 - 41
CSharp/App/BossMonit/Protocol.cs

@@ -1,41 +0,0 @@
-using System.Collections.Generic;
-using System.Runtime.Serialization;
-
-namespace BossMonit
-{
-	[DataContract]
-	public class KVItem
-	{
-		[DataMember(Order = 1, IsRequired = true)]
-		public byte[] Key { get; set; }
-
-		[DataMember(Order = 2, IsRequired = false)]
-		public byte[] Value { get; set; }
-	}
-
-	[DataContract]
-	public class GmRequest
-	{
-		[DataMember(Order = 1, IsRequired = true)]
-		public byte[] Cmd { get; set; }
-
-		[DataMember(Order = 2, IsRequired = false)]
-		public byte[] Param { get; set; }
-
-		[DataMember(Order = 3)]
-		public List<KVItem> ParamList { get; set; }
-	}
-
-	[DataContract]
-	public class GmResult
-	{
-		[DataMember(Order = 1, IsRequired = true)]
-		public int Result { get; set; }
-
-		[DataMember(Order = 2, IsRequired = false)]
-		public byte[] Data { get; set; }
-
-		[DataMember(Order = 3)]
-		public KVItem DataList { get; set; }
-	}
-}

+ 0 - 15
CSharp/CSharp.sln

@@ -48,8 +48,6 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BossCommand", "App\BossComm
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "WCFClient", "App\Modules\WCFClient\WCFClient.csproj", "{B07D70E7-F902-4F67-A486-B7AF27D6B813}"
 EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BossMonit", "App\BossMonit\BossMonit.csproj", "{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}"
-EndProject
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Game", "Game", "{D0CC1FF4-2747-4278-A51F-BE9AA959175B}"
 EndProject
 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Component", "Game\Component\Component.csproj", "{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}"
@@ -268,18 +266,6 @@ Global
 		{B07D70E7-F902-4F67-A486-B7AF27D6B813}.Release|Mixed Platforms.Build.0 = Release|Any CPU
 		{B07D70E7-F902-4F67-A486-B7AF27D6B813}.Release|Win32.ActiveCfg = Release|Any CPU
 		{B07D70E7-F902-4F67-A486-B7AF27D6B813}.Release|x86.ActiveCfg = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|Any CPU.Build.0 = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|Mixed Platforms.Build.0 = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|Win32.ActiveCfg = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Debug|x86.ActiveCfg = Debug|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Any CPU.ActiveCfg = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Any CPU.Build.0 = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Mixed Platforms.ActiveCfg = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Mixed Platforms.Build.0 = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|Win32.ActiveCfg = Release|Any CPU
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2}.Release|x86.ActiveCfg = Release|Any CPU
 		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
 		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Any CPU.Build.0 = Debug|Any CPU
 		{CBEDBE33-A883-4BFA-AE0A-8B3573F09BD0}.Debug|Mixed Platforms.ActiveCfg = Debug|Any CPU
@@ -339,7 +325,6 @@ Global
 		{8650195A-7904-4EBC-9D81-B392A7E9B9B3} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{999910D3-4E7D-45B1-BD2C-47289CD4D1AB} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{6C16281F-5550-4024-9504-295C63889E4F} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
-		{E8C290C1-D4FE-44A5-81A2-507706CF7DF2} = {6E9D97F0-4243-452E-B832-1A855B8118EB}
 		{3A98B35C-DEA8-489C-9203-263FFB6B065D} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{72E16572-FC1F-4A9E-BC96-035417239298} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}
 		{24233CD5-A5DF-484B-A482-B79CB7A0D9CB} = {ADBF5F67-B480-4A93-9D50-C81856FC61A9}