@domain.js/main 0.5.0 → 0.5.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -13,7 +13,8 @@ export declare type Client = Socket<DefaultEventsMap, DefaultEventsMap, DefaultE
13
13
  operator?: any;
14
14
  /** 退出房间回调函数 */
15
15
  quit?: Function;
16
+ entranceOpts?: any[];
16
17
  };
17
- declare const makeProfile: (client: Client, type: string | undefined, auth: string | Signature, extra?: Profile["extra"]) => Profile;
18
+ declare const makeProfile: (client: Client, type: string | undefined, auth: string | Signature | undefined, extra?: Profile["extra"]) => Profile;
18
19
  export declare function BridgeSocket(io: Server, domain: Domain): void;
19
20
  export {};
@@ -58,13 +58,15 @@ const makeProfile = (client, type = "user", auth, extra = {}) => {
58
58
  if (extra.uuid)
59
59
  obj.uuid = extra.uuid;
60
60
  }
61
- if (typeof auth === "string") {
62
- obj.token = auth;
63
- }
64
- else {
65
- obj.sign = auth;
66
- obj.sign.uri = "/socket.io";
67
- obj.sign.method = "socket.init";
61
+ if (auth) {
62
+ if (typeof auth === "string") {
63
+ obj.token = auth;
64
+ }
65
+ else {
66
+ obj.sign = auth;
67
+ obj.sign.uri = "/socket.io";
68
+ obj.sign.method = "socket.init";
69
+ }
68
70
  }
69
71
  return obj;
70
72
  };
@@ -88,10 +90,6 @@ function BridgeSocket(io, domain) {
88
90
  console.log("[%s] connection: client.id: %s", new Date(), client.id);
89
91
  client.on("init", async (type, auth, extra = {}) => {
90
92
  console.log("[%s] socket.init: client.id: %s", new Date(), client.id);
91
- if (!auth) {
92
- client.emit("initError", "auth info lost");
93
- return;
94
- }
95
93
  try {
96
94
  Object.assign(client, { profile: makeProfile(client, type, auth, extra) });
97
95
  if (!client.profile)
@@ -109,10 +107,12 @@ function BridgeSocket(io, domain) {
109
107
  console.error(e);
110
108
  }
111
109
  });
112
- client.on("entrance", async (roomId) => {
110
+ client.on("entrance", async (roomId, ...opts) => {
113
111
  try {
114
112
  if (!client.profile || !client.inited)
115
113
  return;
114
+ if (opts.length)
115
+ Object.assign(client, { entranceOpts: opts });
116
116
  const ret = await entrance({ ...client.profile, roomId }, client);
117
117
  client.profile.roomId = roomId;
118
118
  client.roomId = roomId;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@domain.js/main",
3
- "version": "0.5.0",
3
+ "version": "0.5.3",
4
4
  "description": "DDD framework",
5
5
  "main": "dist/index.js",
6
6
  "bin": {