bytebuf capacity

This commit is contained in:
AMAMA
2016-12-24 13:56:27 +08:00
parent 31f046dfc6
commit 0eb785e77c
5 changed files with 126 additions and 16 deletions

View File

@@ -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.

View File

@@ -54,7 +54,7 @@ namespace cocosocket4unity
{
byte[] old = data;
data = new byte[nc];
Array.Copy (old, data, data.Length);
Array.Copy (old, data, old.Length);
}
return this;
}

View File

@@ -8,13 +8,30 @@ using System.Net;
using protocol;
//引用的
using System.Reflection;
using System.IO;
namespace cocosocket4unity
{
class MainClass
{
public static void Main1 (string[] args)
public static void Main(string[] args)
{
FightFBResultRequest request = new FightFBResultRequest();
request.starList = new List<int>();
request.starList.Add(1);
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.");
}
/**
AuthRequest ar = new AuthRequest();
string json = JsonMapper.ToJson(ar);
Console.WriteLine(ar.GetType().Name+":"+json);
@@ -31,6 +48,7 @@ namespace cocosocket4unity
Console.WriteLine(arr.value);
}
Console.Read();
*/
/**
long time_JAVA_Long = 1446050129676L;//java长整型日期毫秒为单位
@@ -41,6 +59,7 @@ namespace cocosocket4unity
Console.WriteLine(string.Format("{0:G}", dt));
Console.Read();
*/
/**
SocketListner listner = new TestListner ();
USocket us = new USocket ();
us.setLister (listner);
@@ -49,7 +68,7 @@ namespace cocosocket4unity
us.setProtocal (p);
us.Connect ("localhost", 4887);
Console.Read();
*/
}
}
}

View File

@@ -46,7 +46,7 @@ namespace cocosocket4unity
base.HandleTimeout();
}
public static void Main(string[] args)
public static void Main1(string[] args)
{
KcpClient client = new TestKcp(2223);
client.NoDelay(1, 10, 2, 1);//fast

View File

@@ -21,6 +21,7 @@
<WarningLevel>4</WarningLevel>
<PlatformTarget>x86</PlatformTarget>
<Externalconsole>True</Externalconsole>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
<DebugType>none</DebugType>
@@ -32,9 +33,6 @@
<Externalconsole>True</Externalconsole>
</PropertyGroup>
<ItemGroup>
<Reference Include="protobuf-net">
<HintPath>..\..\..\..\..\protobuf-net.dll</HintPath>
</Reference>
<Reference Include="System" />
<Reference Include="System.XML" />
</ItemGroup>
@@ -42,6 +40,7 @@
<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" />
@@ -51,6 +50,95 @@
<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="TestKcp.cs" />
@@ -70,5 +158,8 @@
<Compile Include="CodedOutputStream.cs" />
<Compile Include="Varint32Frame.cs" />
</ItemGroup>
<ItemGroup>
<None Include="Protobuf\project.json" />
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
</Project>