Skip to content

Commit cfc0491

Browse files
author
magiclu550
committed
[proxy] fix a bug about map: field
1 parent c6a0a8a commit cfc0491

File tree

4 files changed

+31
-3
lines changed

4 files changed

+31
-3
lines changed

jsmod2/NetworkHandler.cs

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -595,7 +595,14 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
595595
}
596596
else
597597
{
598-
dArgs[i] = JsonConvert.DeserializeObject(args[i],types[i]);
598+
if (types[i].IsSubclassOf(typeof(Enum)))
599+
{
600+
dArgs[i] = JsonConvert.DeserializeObject(args[i],types[i]);
601+
}
602+
else
603+
{
604+
dArgs[i] = ProxyHandler.handler.apiMapping[args[i]];
605+
}
599606
}
600607

601608
}
@@ -608,7 +615,26 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
608615
}
609616
else
610617
{
611-
return Utils.getOne(mapper["id"], o, null);
618+
if (info.ReturnType.IsSubclassOf(typeof(Enum))||Utils.isCommon(info.ReturnType))
619+
{
620+
return Utils.getOne(mapper["id"], o, null);
621+
}
622+
else
623+
{
624+
if (info.ReturnType == typeof(Door[]))
625+
{
626+
Door[] doors = o as Door[];
627+
JsonSetting[] settings = new JsonSetting[doors.Length];
628+
for (int i = 0; i < doors.Length; i++)
629+
{
630+
settings[i] = new JsonSetting(Lib.getInt(mapper["id"]),null,new IdMapping()
631+
.appendId(Lib.ID,doors[i])
632+
);
633+
}
634+
}
635+
636+
return null;
637+
}
612638
}
613639
}
614640
}
@@ -690,6 +716,7 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
690716
/**
691717
* 可以设置基本类型值,api类型值,枚举值
692718
* 可以返回基本类型值,枚举值
719+
* 这个就是基于反射实现的SimpleHandler,可以阅读ProxyHandler源码
693720
*/
694721
public class SimpleHandler : Handler
695722
{
@@ -711,7 +738,7 @@ public JsonSetting[] handle(object api, Dictionary<string, string> mapper)
711738

712739
Type returnType = obj.GetType();
713740
bool isCommonType = Utils.isCommon(returnType);
714-
if (isCommonType)
741+
if (isCommonType||returnType.IsSubclassOf(typeof(Enum)))
715742
{
716743
return Utils.getOne(mapper["id"], obj, null);
717744
}

jsmod2/bin/Debug/jsmod2.pdb

0 Bytes
Binary file not shown.

jsmod2/command/CommandHandler.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ public CommandHandler(NativeCommand cmd)
2121
this.description = cmd.description;
2222
}
2323

24+
//这里是对于命令的响应处理部分,发出信息,在JSmod2中接受
2425
public string[] OnCall(ICommandSender sender, string[] args)
2526
{
2627
if (sender is Server)

jsmod2/obj/Debug/jsmod2.pdb

0 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)