oschina上同步过来

This commit is contained in:
beykery
2015-12-30 10:57:22 +08:00
parent 6c5f1de041
commit b16b133103
12 changed files with 29 additions and 9 deletions

View File

@@ -37,7 +37,7 @@
<dependency>
<groupId>io.netty</groupId>
<artifactId>netty-all</artifactId>
<version>4.0.30.Final</version>
<version>4.0.33.Final</version>
</dependency>
</dependencies>
<distributionManagement>

View File

@@ -14,7 +14,7 @@ public abstract class NListener
{
private static final Logger LOG = Logger.getLogger(NListener.class.getName());
int max_connection = 1000000;//百万
int max_connection = Integer.MAX_VALUE;
AtomicInteger cur_connection = new AtomicInteger(0);
public abstract void onOpen(NClient conn);

View File

@@ -2,9 +2,9 @@
using System.Collections.Generic;
using System;
namespace cocosocket4unity
namespace protocol
{
[Proto(value=12)]
[Proto(value=6)]
[ProtoContract]
public class AuthRequest // 协议:6
{

View File

@@ -2,8 +2,9 @@
using System.Collections.Generic;
using System;
namespace cocosocket4unity
namespace protocol
{
[Proto(value = -6)]
[ProtoContract]
public class AuthResponse // 协议:-6
{

View File

@@ -13,7 +13,7 @@ namespace cocosocket4unity
List<Type> list = new List<Type>();
foreach (Type type in asm.GetTypes())
{
if (type.Namespace.Equals(nameSpace))
if (nameSpace.Equals(type.Namespace))
list.Add(type);
}
return list;

View File

@@ -5,17 +5,35 @@ using System.Linq;
using System.Text;
using System.Net.Sockets;
using System.Net;
using protocol;
namespace cocosocket4unity
{
class MainClass
{
public static void Main (string[] args)
{
AuthRequest ar = new AuthRequest();
string json = JsonMapper.ToJson(ar);
Console.WriteLine(ar.GetType().Name+":"+json);
List<Type> ls = ClassUtil.GetClasses("protocol");
foreach (Type item in ls)
{
Console.WriteLine(item.Name);
ProtoAttribute arr= (ProtoAttribute)ClassUtil.GetAttribute(item,typeof(ProtoAttribute));
if(arr!=null)
Console.WriteLine(arr.value);
}
Console.Read();
/**
long time_JAVA_Long = 1446050129676L;//java长整型日期毫秒为单位
DateTime dt_1970 = new DateTime(1970, 1, 1, 0, 0, 0);
long tricks_1970 = dt_1970.Ticks;//1970年1月1
long time_tricks = tricks_1970 + time_JAVA_Long * 10000;//日志日期刻度
DateTime dt = new DateTime(time_tricks).AddHours(8);//转化为DateTime
Console.WriteLine(string.Format("{0:G}", dt));
Console.Read();
SocketListner listner = new TestListner ();
USocket us = new USocket ();
us.setLister (listner);
@@ -24,7 +42,7 @@ namespace cocosocket4unity
us.setProtocal (p);
us.Connect ("localhost", 4887);
Console.Read();
*/
}
}
}

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace cocosocket4unity
namespace protocol
{
[AttributeUsage(AttributeTargets.Class)]
class ProtoAttribute : Attribute

View File

@@ -4,6 +4,7 @@ using ProtoBuf.Serializers;
using System.Collections.Generic;
using System;
using System.IO;
using protocol;
namespace cocosocket4unity
{
public class TestListner : SocketListner