Skip to content

Commit

Permalink
oschina上同步过来
Browse files Browse the repository at this point in the history
  • Loading branch information
williamoony committed Dec 30, 2015
1 parent 6c5f1de commit b16b133
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 9 deletions.
2 changes: 1 addition & 1 deletion cocosocket/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
2 changes: 1 addition & 1 deletion cocosocket/src/main/java/org/ngame/socket/NListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 2 additions & 2 deletions cocosocket4unity/cocosocket4unity/AuthRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
3 changes: 2 additions & 1 deletion cocosocket4unity/cocosocket4unity/AuthResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@
using System.Collections.Generic;
using System;

namespace cocosocket4unity
namespace protocol
{
[Proto(value = -6)]
[ProtoContract]
public class AuthResponse // 协议:-6
{
Expand Down
2 changes: 1 addition & 1 deletion cocosocket4unity/cocosocket4unity/ClassUtil.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ public static List<Type> GetClasses(string nameSpace)
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;
Expand Down
22 changes: 20 additions & 2 deletions cocosocket4unity/cocosocket4unity/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,35 @@
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);
Expand All @@ -24,7 +42,7 @@ public static void Main (string[] args)
us.setProtocal (p);
us.Connect ("localhost", 4887);
Console.Read();
*/

}
}
}
2 changes: 1 addition & 1 deletion cocosocket4unity/cocosocket4unity/ProtoAttribute.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
using System.Linq;
using System.Text;

namespace cocosocket4unity
namespace protocol
{
[AttributeUsage(AttributeTargets.Class)]
class ProtoAttribute : Attribute
Expand Down
1 change: 1 addition & 0 deletions cocosocket4unity/cocosocket4unity/TestListner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using System.Collections.Generic;
using System;
using System.IO;
using protocol;
namespace cocosocket4unity
{
public class TestListner : SocketListner
Expand Down
Binary file modified cocosocket4unity/cocosocket4unity/bin/Debug/cocosocket4unity.exe
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.

0 comments on commit b16b133

Please sign in to comment.