mirror of
https://github.com/beykery/cocosocket.git
synced 2026-09-03 06:15:40 +08:00
from git.oschina
“ “
This commit is contained in:
@@ -13,6 +13,7 @@ import io.netty.channel.ChannelPipeline;
|
||||
import io.netty.channel.EventLoopGroup;
|
||||
import io.netty.channel.ServerChannel;
|
||||
import io.netty.channel.epoll.Epoll;
|
||||
import io.netty.channel.epoll.EpollChannelOption;
|
||||
import io.netty.channel.epoll.EpollEventLoopGroup;
|
||||
import io.netty.channel.epoll.EpollServerSocketChannel;
|
||||
import io.netty.channel.local.LocalAddress;
|
||||
|
||||
BIN
cocosocket4unity/cocosocket4unity.v12.suo
Normal file
BIN
cocosocket4unity/cocosocket4unity.v12.suo
Normal file
Binary file not shown.
@@ -4,20 +4,20 @@ using System.Runtime.CompilerServices;
|
||||
// Information about this assembly is defined by the following attributes.
|
||||
// Change them to the values specific to your project.
|
||||
|
||||
//[assembly: AssemblyTitle("cocosocket4unity")]
|
||||
//[assembly: AssemblyDescription("")]
|
||||
//[assembly: AssemblyConfiguration("")]
|
||||
//[assembly: AssemblyCompany("")]
|
||||
//[assembly: AssemblyProduct("")]
|
||||
//[assembly: AssemblyCopyright("Administrator")]
|
||||
//[assembly: AssemblyTrademark("")]
|
||||
//[assembly: AssemblyCulture("")]
|
||||
[assembly: AssemblyTitle("cocosocket4unity")]
|
||||
[assembly: AssemblyDescription("")]
|
||||
[assembly: AssemblyConfiguration("")]
|
||||
[assembly: AssemblyCompany("")]
|
||||
[assembly: AssemblyProduct("")]
|
||||
[assembly: AssemblyCopyright("Administrator")]
|
||||
[assembly: AssemblyTrademark("")]
|
||||
[assembly: AssemblyCulture("")]
|
||||
|
||||
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
|
||||
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
|
||||
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
|
||||
|
||||
//[assembly: AssemblyVersion("1.0.*")]
|
||||
[assembly: AssemblyVersion("1.0.*")]
|
||||
|
||||
// The following attributes are used to specify the signing key for the assembly,
|
||||
// if desired. See the Mono documentation for more information about signing.
|
||||
|
||||
@@ -13,10 +13,17 @@ namespace cocosocket4unity
|
||||
public abstract class KcpClient : KcpOnUdp
|
||||
{
|
||||
protected volatile bool running;
|
||||
/// <summary>
|
||||
/// kcp,随机分配一个端口
|
||||
/// </summary>
|
||||
public KcpClient():base(0)
|
||||
{
|
||||
}
|
||||
/// <summary>
|
||||
/// 初始化kcp
|
||||
/// </summary>
|
||||
/// <param name="port">监听端口</param>
|
||||
///
|
||||
public KcpClient(int port):base(port)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,6 +26,12 @@ namespace cocosocket4unity
|
||||
protected volatile bool needUpdate;
|
||||
protected long timeout;//超时
|
||||
protected DateTime lastTime;//上次检测时间
|
||||
/// <summary>
|
||||
/// 客户端
|
||||
/// </summary>
|
||||
public KcpOnUdp():this(0)
|
||||
{
|
||||
}
|
||||
public KcpOnUdp(int port)
|
||||
{
|
||||
client = new UdpClient(port);
|
||||
|
||||
@@ -6,31 +6,24 @@ using System.Text;
|
||||
using System.Net.Sockets;
|
||||
using System.Net;
|
||||
using protocol;
|
||||
//引用的
|
||||
using System.Reflection;
|
||||
using System.IO;
|
||||
|
||||
namespace cocosocket4unity
|
||||
{
|
||||
class MainClass
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
public static void Main0 (string[] args)
|
||||
{
|
||||
|
||||
FightFBResultRequest request = new FightFBResultRequest();
|
||||
request.starList = new List<int>();
|
||||
request.starList.Add(1);
|
||||
TestRequest request = new TestRequest();
|
||||
request.c = TestEnum.WHITE;
|
||||
MemoryStream stream = new MemoryStream();
|
||||
ProtoBuf.Serializer.NonGeneric.Serialize(stream, request);
|
||||
byte[] bs = stream.ToArray();
|
||||
try{
|
||||
FileStream fsWrite = new FileStream("./request.data", FileMode.Create);
|
||||
fsWrite.Write(bs, 0, bs.Length);
|
||||
}catch(Exception ex)
|
||||
{
|
||||
Console.WriteLine("error.");
|
||||
}
|
||||
|
||||
|
||||
Type type = typeof(TestRequest);
|
||||
Stream s = stream;
|
||||
request= (TestRequest)ProtoBuf.Serializer.NonGeneric.Deserialize(type, s);
|
||||
Console.WriteLine(request);
|
||||
/**
|
||||
AuthRequest ar = new AuthRequest();
|
||||
string json = JsonMapper.ToJson(ar);
|
||||
@@ -48,8 +41,7 @@ namespace cocosocket4unity
|
||||
Console.WriteLine(arr.value);
|
||||
}
|
||||
Console.Read();
|
||||
*/
|
||||
|
||||
*/
|
||||
/**
|
||||
long time_JAVA_Long = 1446050129676L;//java长整型日期,毫秒为单位
|
||||
DateTime dt_1970 = new DateTime(1970, 1, 1, 0, 0, 0);
|
||||
@@ -69,6 +61,7 @@ namespace cocosocket4unity
|
||||
us.Connect ("localhost", 4887);
|
||||
Console.Read();
|
||||
*/
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
28
cocosocket4unity/cocosocket4unity/TestEnum.cs
Normal file
28
cocosocket4unity/cocosocket4unity/TestEnum.cs
Normal file
@@ -0,0 +1,28 @@
|
||||
using ProtoBuf;
|
||||
using System.Collections.Generic;
|
||||
using System.Runtime.Serialization;
|
||||
using System.ComponentModel;
|
||||
using System;
|
||||
|
||||
namespace protocol
|
||||
{
|
||||
[ProtoContract]
|
||||
public enum TestEnum
|
||||
{
|
||||
/// <summary>
|
||||
/// 白
|
||||
/// </summary>
|
||||
//[EnumMember]
|
||||
[ProtoEnum]
|
||||
[Description("白")]
|
||||
WHITE=0,
|
||||
/// <summary>
|
||||
/// 绿
|
||||
/// </summary>
|
||||
//[EnumMember]
|
||||
[ProtoEnum]
|
||||
[Description("绿")]
|
||||
GREEN=1
|
||||
|
||||
}
|
||||
}
|
||||
@@ -20,10 +20,6 @@ namespace cocosocket4unity
|
||||
{
|
||||
public class TestKcp : KcpClient
|
||||
{
|
||||
public TestKcp(int port): base(port)
|
||||
{
|
||||
|
||||
}
|
||||
protected override void HandleReceive(ByteBuf bb)
|
||||
{
|
||||
string content= System.Text.Encoding.UTF8.GetString(bb.GetRaw());
|
||||
@@ -46,16 +42,16 @@ namespace cocosocket4unity
|
||||
base.HandleTimeout();
|
||||
}
|
||||
|
||||
public static void Main1(string[] args)
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
KcpClient client = new TestKcp(2223);
|
||||
KcpClient client = new TestKcp();
|
||||
client.NoDelay(1, 10, 2, 1);//fast
|
||||
client.WndSize(64, 64);
|
||||
client.Timeout(10*1000);
|
||||
client.SetMtu(512);
|
||||
client.SetMinRto(10);
|
||||
client.Connect("119.29.153.92", 2222);
|
||||
//client.Connect("127.0.0.1", 2222);
|
||||
//client.Connect("119.29.153.92", 2222);
|
||||
client.Connect("127.0.0.1", 2222);
|
||||
client.Start();
|
||||
Thread.Sleep(2000);
|
||||
String s = "hi,heoll world! 你好啊!!";
|
||||
|
||||
21
cocosocket4unity/cocosocket4unity/TestRequest.cs
Normal file
21
cocosocket4unity/cocosocket4unity/TestRequest.cs
Normal file
@@ -0,0 +1,21 @@
|
||||
using ProtoBuf;
|
||||
using System.Collections.Generic;
|
||||
using System;
|
||||
|
||||
namespace protocol
|
||||
{
|
||||
/// <summary>
|
||||
/// 测试em 协议:900
|
||||
/// </summary>
|
||||
[Proto(value=900,description="测试em")]
|
||||
[ProtoContract]
|
||||
public class TestRequest
|
||||
{
|
||||
/// <summary>
|
||||
/// 颜色
|
||||
/// </summary>
|
||||
[ProtoMember(1, IsRequired = false)]
|
||||
public TestEnum c;
|
||||
|
||||
}
|
||||
}
|
||||
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/cocosocket4unity.exe
Normal file
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/cocosocket4unity.exe
Normal file
Binary file not shown.
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/cocosocket4unity.pdb
Normal file
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/cocosocket4unity.pdb
Normal file
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
|
||||
<security>
|
||||
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false"/>
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
</assembly>
|
||||
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.dll
Normal file
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.dll
Normal file
Binary file not shown.
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.pdb
Normal file
BIN
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.pdb
Normal file
Binary file not shown.
2758
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.xml
Normal file
2758
cocosocket4unity/cocosocket4unity/bin/Debug/protobuf-net.xml
Normal file
File diff suppressed because it is too large
Load Diff
@@ -21,7 +21,6 @@
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<Externalconsole>True</Externalconsole>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>none</DebugType>
|
||||
@@ -33,6 +32,9 @@
|
||||
<Externalconsole>True</Externalconsole>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="protobuf-net">
|
||||
<HintPath>..\..\..\..\..\迅雷下载\protobuf-net\csharp\net20\protobuf-net.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.XML" />
|
||||
</ItemGroup>
|
||||
@@ -40,7 +42,6 @@
|
||||
<Compile Include="AuthRequest.cs" />
|
||||
<Compile Include="AuthResponse.cs" />
|
||||
<Compile Include="ClassUtil.cs" />
|
||||
<Compile Include="FightFBResultRequest.cs" />
|
||||
<Compile Include="Kcp.cs" />
|
||||
<Compile Include="KcpClient.cs" />
|
||||
<Compile Include="KcpOnUdp.cs" />
|
||||
@@ -50,98 +51,11 @@
|
||||
<Compile Include="Frame.cs" />
|
||||
<Compile Include="Output.cs" />
|
||||
<Compile Include="ProtoAttribute.cs" />
|
||||
<Compile Include="Protobuf\BclHelpers.cs" />
|
||||
<Compile Include="Protobuf\BufferExtension.cs" />
|
||||
<Compile Include="Protobuf\BufferPool.cs" />
|
||||
<Compile Include="Protobuf\CallbackAttributes.cs" />
|
||||
<Compile Include="Protobuf\Compiler\CompilerContext.cs" />
|
||||
<Compile Include="Protobuf\Compiler\CompilerDelegates.cs" />
|
||||
<Compile Include="Protobuf\Compiler\Local.cs" />
|
||||
<Compile Include="Protobuf\DataFormat.cs" />
|
||||
<Compile Include="Protobuf\Extensible.cs" />
|
||||
<Compile Include="Protobuf\ExtensibleUtil.cs" />
|
||||
<Compile Include="Protobuf\GlobalSuppressions.cs" />
|
||||
<Compile Include="Protobuf\Helpers.cs" />
|
||||
<Compile Include="Protobuf\IExtensible.cs" />
|
||||
<Compile Include="Protobuf\IExtension.cs" />
|
||||
<Compile Include="Protobuf\ImplicitFields.cs" />
|
||||
<Compile Include="Protobuf\KeyValuePairProxy.cs" />
|
||||
<Compile Include="Protobuf\Meta\AttributeMap.cs" />
|
||||
<Compile Include="Protobuf\Meta\BasicList.cs" />
|
||||
<Compile Include="Protobuf\Meta\CallbackSet.cs" />
|
||||
<Compile Include="Protobuf\Meta\MetaType.cs" />
|
||||
<Compile Include="Protobuf\Meta\RuntimeTypeModel.cs" />
|
||||
<Compile Include="Protobuf\Meta\SubType.cs" />
|
||||
<Compile Include="Protobuf\Meta\TypeFormatEventArgs.cs" />
|
||||
<Compile Include="Protobuf\Meta\TypeModel.cs" />
|
||||
<Compile Include="Protobuf\Meta\ValueMember.cs" />
|
||||
<Compile Include="Protobuf\NetObjectCache.cs" />
|
||||
<Compile Include="Protobuf\PrefixStyle.cs" />
|
||||
<Compile Include="Protobuf\Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="Protobuf\ProtoContractAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoConverterAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoEnumAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoException.cs" />
|
||||
<Compile Include="Protobuf\ProtoIgnoreAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoIncludeAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoMemberAttribute.cs" />
|
||||
<Compile Include="Protobuf\ProtoReader.cs" />
|
||||
<Compile Include="Protobuf\ProtoWriter.cs" />
|
||||
<Compile Include="Protobuf\SerializationContext.cs" />
|
||||
<Compile Include="Protobuf\Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ArrayDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\BlobSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\BooleanSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ByteSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\CharSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\CompiledSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\DateTimeSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\DecimalSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\DefaultValueDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\DoubleSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\EnumSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\FieldDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\GuidSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ImmutableCollectionDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\Int16Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\Int32Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\Int64Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\IProtoSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\IProtoTypeSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ISerializerProxy.cs" />
|
||||
<Compile Include="Protobuf\Serializers\KeyValuePairDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ListDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\MemberSpecifiedDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\NetObjectSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\NullDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ParseableSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\PropertyDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ProtoDecoratorBase.cs" />
|
||||
<Compile Include="Protobuf\Serializers\ReflectedUriDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\SByteSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\SingleSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\StringSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\SubItemSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\SurrogateSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\SystemTypeSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\TagDecorator.cs" />
|
||||
<Compile Include="Protobuf\Serializers\TimeSpanSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\TupleSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\TypeSerializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\UInt16Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\UInt32Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\UInt64Serializer.cs" />
|
||||
<Compile Include="Protobuf\Serializers\UriDecorator.cs" />
|
||||
<Compile Include="Protobuf\ServiceModel\ProtoBehaviorAttribute.cs" />
|
||||
<Compile Include="Protobuf\ServiceModel\ProtoBehaviorExtensionElement.cs" />
|
||||
<Compile Include="Protobuf\ServiceModel\ProtoEndpointBehavior.cs" />
|
||||
<Compile Include="Protobuf\ServiceModel\ProtoOperationBehavior.cs" />
|
||||
<Compile Include="Protobuf\ServiceModel\XmlProtoSerializer.cs" />
|
||||
<Compile Include="Protobuf\SubItemToken.cs" />
|
||||
<Compile Include="Protobuf\WireType.cs" />
|
||||
<Compile Include="Protocal.cs" />
|
||||
<Compile Include="LVProtocal.cs" />
|
||||
<Compile Include="TestEnum.cs" />
|
||||
<Compile Include="TestKcp.cs" />
|
||||
<Compile Include="TestRequest.cs" />
|
||||
<Compile Include="USocket.cs" />
|
||||
<Compile Include="SocketListner.cs" />
|
||||
<Compile Include="TestListner.cs" />
|
||||
@@ -158,8 +72,5 @@
|
||||
<Compile Include="CodedOutputStream.cs" />
|
||||
<Compile Include="Varint32Frame.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Protobuf\project.json" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
||||
Binary file not shown.
@@ -0,0 +1,8 @@
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\bin\Debug\cocosocket4unity.exe
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\bin\Debug\cocosocket4unity.pdb
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\bin\Debug\protobuf-net.dll
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\bin\Debug\protobuf-net.pdb
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\bin\Debug\protobuf-net.xml
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\obj\x86\Debug\cocosocket4unity.exe
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\obj\x86\Debug\cocosocket4unity.pdb
|
||||
D:\work\git\cocosocket\cocosocket4unity\cocosocket4unity\obj\x86\Debug\cocosocket4unity.csprojResolveAssemblyReference.cache
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
BIN
unityClientSample/unityClientSample.v12.suo
Normal file
BIN
unityClientSample/unityClientSample.v12.suo
Normal file
Binary file not shown.
Reference in New Issue
Block a user