|
1 | | -namespace KBEngine |
2 | | -{ |
3 | | - using UnityEngine; |
4 | | - using System; |
5 | | - using System.Collections; |
6 | | - using System.Collections.Generic; |
7 | | - |
8 | | - /* |
9 | | - 实体的Mailbox |
10 | | - 关于Mailbox请参考API手册中对它的描述 |
11 | | - https://github.com/kbengine/kbengine/tree/master/docs/api |
12 | | - */ |
13 | | - public class Mailbox |
14 | | - { |
15 | | - // Mailbox的类别 |
16 | | - public enum MAILBOX_TYPE |
17 | | - { |
18 | | - MAILBOX_TYPE_CELL = 0, // CELL_MAILBOX |
19 | | - MAILBOX_TYPE_BASE = 1 // BASE_MAILBOX |
20 | | - } |
21 | | - |
22 | | - public Int32 id = 0; |
23 | | - public string className = ""; |
24 | | - public MAILBOX_TYPE type = MAILBOX_TYPE.MAILBOX_TYPE_CELL; |
25 | | - |
26 | | - private NetworkInterface networkInterface_; |
27 | | - |
28 | | - public Bundle bundle = null; |
29 | | - |
30 | | - public Mailbox() |
31 | | - { |
32 | | - networkInterface_ = KBEngineApp.app.networkInterface(); |
33 | | - } |
34 | | - |
35 | | - public virtual void __init__() |
36 | | - { |
37 | | - } |
38 | | - |
39 | | - bool isBase() |
40 | | - { |
41 | | - return type == MAILBOX_TYPE.MAILBOX_TYPE_BASE; |
42 | | - } |
43 | | - |
44 | | - bool isCell() |
45 | | - { |
46 | | - return type == MAILBOX_TYPE.MAILBOX_TYPE_CELL; |
47 | | - } |
48 | | - |
49 | | - /* |
50 | | - 创建新的mail |
51 | | - */ |
52 | | - public Bundle newMail() |
53 | | - { |
54 | | - if(bundle == null) |
55 | | - bundle = Bundle.createObject(); |
56 | | - |
57 | | - if(type == Mailbox.MAILBOX_TYPE.MAILBOX_TYPE_CELL) |
58 | | - bundle.newMessage(Message.messages["Baseapp_onRemoteCallCellMethodFromClient"]); |
59 | | - else |
60 | | - bundle.newMessage(Message.messages["Base_onRemoteMethodCall"]); |
61 | | - |
62 | | - bundle.writeInt32(this.id); |
63 | | - |
64 | | - return bundle; |
65 | | - } |
66 | | - |
67 | | - /* |
68 | | - 向服务端发送这个mail |
69 | | - */ |
70 | | - public void postMail(Bundle inbundle) |
71 | | - { |
72 | | - if(inbundle == null) |
73 | | - inbundle = bundle; |
74 | | - |
75 | | - inbundle.send(networkInterface_); |
76 | | - |
77 | | - if(inbundle == bundle) |
78 | | - bundle = null; |
79 | | - } |
80 | | - } |
81 | | - |
82 | | -} |
| 1 | +namespace KBEngine |
| 2 | +{ |
| 3 | + using UnityEngine; |
| 4 | + using System; |
| 5 | + using System.Collections; |
| 6 | + using System.Collections.Generic; |
| 7 | + |
| 8 | + /* |
| 9 | + 实体的EntityCall |
| 10 | + 关于EntityCall请参考API手册中对它的描述 |
| 11 | + https://github.com/kbengine/kbengine/tree/master/docs/api |
| 12 | + */ |
| 13 | + public class EntityCall |
| 14 | + { |
| 15 | + // EntityCall的类别 |
| 16 | + public enum ENTITYCALL_TYPE |
| 17 | + { |
| 18 | + ENTITYCALL_TYPE_CELL = 0, // CELL_ENTITYCALL |
| 19 | + ENTITYCALL_TYPE_BASE = 1 // BASE_ENTITYCALL |
| 20 | + } |
| 21 | + |
| 22 | + public Int32 id = 0; |
| 23 | + public string className = ""; |
| 24 | + public ENTITYCALL_TYPE type = ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; |
| 25 | + |
| 26 | + private NetworkInterface networkInterface_; |
| 27 | + |
| 28 | + public Bundle bundle = null; |
| 29 | + |
| 30 | + public EntityCall() |
| 31 | + { |
| 32 | + networkInterface_ = KBEngineApp.app.networkInterface(); |
| 33 | + } |
| 34 | + |
| 35 | + public virtual void __init__() |
| 36 | + { |
| 37 | + } |
| 38 | + |
| 39 | + bool isBase() |
| 40 | + { |
| 41 | + return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_BASE; |
| 42 | + } |
| 43 | + |
| 44 | + bool isCell() |
| 45 | + { |
| 46 | + return type == ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL; |
| 47 | + } |
| 48 | + |
| 49 | + /* |
| 50 | + 创建新的call |
| 51 | + */ |
| 52 | + public Bundle newCall() |
| 53 | + { |
| 54 | + if(bundle == null) |
| 55 | + bundle = Bundle.createObject(); |
| 56 | + |
| 57 | + if(type == EntityCall.ENTITYCALL_TYPE.ENTITYCALL_TYPE_CELL) |
| 58 | + bundle.newMessage(Message.messages["Baseapp_onRemoteCallCellMethodFromClient"]); |
| 59 | + else |
| 60 | + bundle.newMessage(Message.messages["Base_onRemoteMethodCall"]); |
| 61 | + |
| 62 | + bundle.writeInt32(this.id); |
| 63 | + |
| 64 | + return bundle; |
| 65 | + } |
| 66 | + |
| 67 | + /* |
| 68 | + 向服务端发送这个call |
| 69 | + */ |
| 70 | + public void sendCall(Bundle inbundle) |
| 71 | + { |
| 72 | + if(inbundle == null) |
| 73 | + inbundle = bundle; |
| 74 | + |
| 75 | + inbundle.send(networkInterface_); |
| 76 | + |
| 77 | + if(inbundle == bundle) |
| 78 | + bundle = null; |
| 79 | + } |
| 80 | + } |
| 81 | + |
| 82 | +} |
0 commit comments