@xmobitea/gn-typescript-client 0.0.4 → 1.0.9

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.
Files changed (62) hide show
  1. package/dist/gn.js.client.min.js +2 -0
  2. package/dist/gn.js.client.min.js.LICENSE.txt +14 -0
  3. package/dist/index.d.ts +99 -9
  4. package/dist/index.js +1 -1
  5. package/dist/runtime/GNNetwork.d.ts +51 -10
  6. package/dist/runtime/common/Action0.d.ts +1 -3
  7. package/dist/runtime/common/Action1.d.ts +1 -3
  8. package/dist/runtime/common/Action2.d.ts +1 -3
  9. package/dist/runtime/common/Action3.d.ts +1 -3
  10. package/dist/runtime/common/Action4.d.ts +1 -3
  11. package/dist/runtime/common/GNData.d.ts +1 -1
  12. package/dist/runtime/constant/EventCode.d.ts +3 -0
  13. package/dist/runtime/constant/OperationCode.d.ts +15 -0
  14. package/dist/runtime/constant/errorCode/ChatErrorCode.d.ts +4 -0
  15. package/dist/runtime/constant/errorCode/FriendErrorCode.d.ts +4 -0
  16. package/dist/runtime/constant/parameterCode/ChatParameterCode.d.ts +22 -0
  17. package/dist/runtime/constant/parameterCode/FriendParameterCode.d.ts +12 -0
  18. package/dist/runtime/entity/DataMember.d.ts +76 -0
  19. package/dist/runtime/entity/GNMetadata.d.ts +21 -0
  20. package/dist/runtime/entity/request/AddFriendOperationRequest.d.ts +6 -0
  21. package/dist/runtime/entity/request/EditChatInfoChannelOperationRequest.d.ts +7 -0
  22. package/dist/runtime/entity/request/EditChatMessageChannelOperationRequest.d.ts +6 -0
  23. package/dist/runtime/entity/request/EditChatMessageUserOperationRequest.d.ts +6 -0
  24. package/dist/runtime/entity/request/FindPlayerOperationRequest.d.ts +6 -0
  25. package/dist/runtime/entity/request/GetChatInfoChannelOperationRequest.d.ts +6 -0
  26. package/dist/runtime/entity/request/GetChatMemberChannelOperationRequest.d.ts +6 -0
  27. package/dist/runtime/entity/request/GetChatMessageChannelOperationRequest.d.ts +6 -0
  28. package/dist/runtime/entity/request/GetChatMessageUserOperationRequest.d.ts +6 -0
  29. package/dist/runtime/entity/request/GetFriendsOperationRequest.d.ts +6 -0
  30. package/dist/runtime/entity/request/JoinChatChannelOperationRequest.d.ts +6 -0
  31. package/dist/runtime/entity/request/LeaveChatChannelOperationRequest.d.ts +6 -0
  32. package/dist/runtime/entity/request/RemoveFriendOperationRequest.d.ts +6 -0
  33. package/dist/runtime/entity/request/SendChatToChannelOperationRequest.d.ts +6 -0
  34. package/dist/runtime/entity/request/SendChatToUserOperationRequest.d.ts +6 -0
  35. package/dist/runtime/entity/response/AddFriendOperationResponse.d.ts +5 -0
  36. package/dist/runtime/entity/response/EditChatInfoChannelOperationResponse.d.ts +5 -0
  37. package/dist/runtime/entity/response/EditChatMessageChannelOperationResponse.d.ts +5 -0
  38. package/dist/runtime/entity/response/EditChatMessageUserOperationResponse.d.ts +5 -0
  39. package/dist/runtime/entity/response/FindPlayerOperationResponse.d.ts +6 -0
  40. package/dist/runtime/entity/response/GetChatInfoChannelOperationResponse.d.ts +18 -0
  41. package/dist/runtime/entity/response/GetChatMemberChannelOperationResponse.d.ts +14 -0
  42. package/dist/runtime/entity/response/GetChatMessageChannelOperationResponse.d.ts +20 -0
  43. package/dist/runtime/entity/response/GetChatMessageUserOperationResponse.d.ts +17 -0
  44. package/dist/runtime/entity/response/GetFriendsOperationResponse.d.ts +13 -0
  45. package/dist/runtime/entity/response/JoinChatChannelOperationResponse.d.ts +5 -0
  46. package/dist/runtime/entity/response/LeaveChatChannelOperationResponse.d.ts +5 -0
  47. package/dist/runtime/entity/response/RemoveFriendOperationResponse.d.ts +5 -0
  48. package/dist/runtime/entity/response/SendChatToChannelOperationResponse.d.ts +5 -0
  49. package/dist/runtime/entity/response/SendChatToUserOperationResponse.d.ts +5 -0
  50. package/dist/runtime/entity/server/AvatarChannel.d.ts +4 -0
  51. package/dist/runtime/entity/server/ChatChannel.d.ts +13 -0
  52. package/dist/runtime/entity/server/ChatMessage.d.ts +10 -0
  53. package/dist/runtime/entity/server/ChatUser.d.ts +5 -0
  54. package/dist/runtime/entity/server/FriendItem.d.ts +7 -0
  55. package/dist/runtime/entity/server/UserChannel.d.ts +4 -0
  56. package/dist/runtime/helper/ConverterService.d.ts +15 -0
  57. package/dist/runtime/networking/NetworkingPeer.d.ts +42 -0
  58. package/dist/runtime/networking/SocketPeer.d.ts +5 -1
  59. package/dist/runtime/networking/handler/OnChannelChatEventHandler.d.ts +6 -0
  60. package/dist/runtime/networking/handler/OnFriendUpdateEventHandler.d.ts +6 -0
  61. package/dist/runtime/networking/handler/OnUserChatEventHandler.d.ts +6 -0
  62. package/package.json +39 -37
@@ -0,0 +1,10 @@
1
+ export declare class EditChatMessage {
2
+ message: string;
3
+ tsCreate: number;
4
+ }
5
+ export declare class ChatMessage extends EditChatMessage {
6
+ tsLastUpdate: number;
7
+ messageEditeds: EditChatMessage[];
8
+ senderId: string;
9
+ isDelete: boolean;
10
+ }
@@ -0,0 +1,5 @@
1
+ import { ChatMessage } from "./ChatMessage";
2
+ export declare class ChatUser {
3
+ userId: string;
4
+ messages: ChatMessage[];
5
+ }
@@ -0,0 +1,7 @@
1
+ import { FriendStatus } from "./../../constant/enumType/FriendStatus";
2
+ export declare class FriendItem {
3
+ friendId: string;
4
+ friendStatus: FriendStatus;
5
+ isSocialLoginFriend: boolean;
6
+ tsLastUpdate: number;
7
+ }
@@ -0,0 +1,4 @@
1
+ export declare class UserChannel {
2
+ userId: string;
3
+ tsJoin: number;
4
+ }
@@ -0,0 +1,15 @@
1
+ import { GNHashtable } from "./../common/GNData";
2
+ type Constructor<T> = {
3
+ new (...args: any[]): T;
4
+ };
5
+ export interface IGNObject {
6
+ parameters: GNHashtable;
7
+ isValid: boolean;
8
+ }
9
+ export declare class ConvertService {
10
+ private readonly declaredFieldsMap;
11
+ convertObject<T extends IGNObject>(parameters: GNHashtable, cls: Constructor<T>): T;
12
+ private isInteger;
13
+ constructor();
14
+ }
15
+ export {};
@@ -18,6 +18,25 @@ import { RegisterSocketOperationResponse } from "./../entity/response/RegisterSo
18
18
  import { TemplateOperationResponse } from "./../entity/response/TemplateOperationResponse";
19
19
  import { IServerEventHandler } from "./handler/IServerEventHandler";
20
20
  import { HttpAppResponse } from "./HttpPeer";
21
+ import { OperationEvent } from "./../entity/OperationEvent";
22
+ import { FriendItem } from "./../entity/server/FriendItem";
23
+ import { ChatChannel } from "./../entity/server/ChatChannel";
24
+ import { ChatUser } from "./../entity/server/ChatUser";
25
+ import { AddFriendOperationResponse } from "./../entity/response/AddFriendOperationResponse";
26
+ import { RemoveFriendOperationResponse } from "./../entity/response/RemoveFriendOperationResponse";
27
+ import { GetFriendsOperationResponse } from "./../entity/response/GetFriendsOperationResponse";
28
+ import { FindPlayerOperationResponse } from "./../entity/response/FindPlayerOperationResponse";
29
+ import { SendChatToUserOperationResponse } from "./../entity/response/SendChatToUserOperationResponse";
30
+ import { GetChatMessageUserOperationResponse } from "./../entity/response/GetChatMessageUserOperationResponse";
31
+ import { SendChatToChannelOperationResponse } from "./../entity/response/SendChatToChannelOperationResponse";
32
+ import { JoinChatChannelOperationResponse } from "./../entity/response/JoinChatChannelOperationResponse";
33
+ import { LeaveChatChannelOperationResponse } from "./../entity/response/LeaveChatChannelOperationResponse";
34
+ import { GetChatInfoChannelOperationResponse } from "./../entity/response/GetChatInfoChannelOperationResponse";
35
+ import { GetChatMessageChannelOperationResponse } from "./../entity/response/GetChatMessageChannelOperationResponse";
36
+ import { GetChatMemberChannelOperationResponse } from "./../entity/response/GetChatMemberChannelOperationResponse";
37
+ import { EditChatInfoChannelOperationResponse } from "./../entity/response/EditChatInfoChannelOperationResponse";
38
+ import { EditChatMessageChannelOperationResponse } from "./../entity/response/EditChatMessageChannelOperationResponse";
39
+ import { EditChatMessageUserOperationResponse } from "./../entity/response/EditChatMessageUserOperationResponse";
21
40
  export declare class NetworkingPeer {
22
41
  static readonly SYNC_TS: string;
23
42
  static readonly UPLOAD_FILE: string;
@@ -29,7 +48,14 @@ export declare class NetworkingPeer {
29
48
  private httpPeer;
30
49
  authToken: string;
31
50
  userId: string;
51
+ friendItemLst: FriendItem[];
52
+ onFriendItemChange: Action1<FriendItem>;
53
+ chatChannelLst: ChatChannel[];
54
+ onChatChannelChange: Action1<ChatChannel>;
55
+ chatUserLst: ChatUser[];
56
+ onChatUserChange: Action1<ChatUser>;
32
57
  getPing(): number;
58
+ getClientId(): string;
33
59
  private update;
34
60
  private service;
35
61
  private lastCurrentServerMilliseconds;
@@ -42,6 +68,7 @@ export declare class NetworkingPeer {
42
68
  sendRequestAuthSocket(): void;
43
69
  connectSocket(_onSocketConnect: Action0): void;
44
70
  disconnectSocket(_onSocketDisconnect: Action0): void;
71
+ setOnEventHandler(_onEventHandler: Action1<OperationEvent>): void;
45
72
  setOnConnectHandler(_onConnectHandler: Action0): void;
46
73
  setOnDisconnectHandler(_onDisconnectHandler: Action0): void;
47
74
  removeOnConnectHandler(_onConnectHandler: Action0): void;
@@ -71,4 +98,19 @@ export declare class NetworkingPeer {
71
98
  createNewFileUploadInfo(originFileName: string, onResponse?: Action1<CreateNewFileUploadInfoOperationResponse>): void;
72
99
  getFileUploadInfo(fileId: string, onResponse?: Action1<GetFileUploadInfoOperationResponse>): void;
73
100
  logout(onResponse?: Action1<LogoutOperationResponse>): void;
101
+ addFriend(friendId: string, forceAcceptFriend?: boolean, onResponse?: Action1<AddFriendOperationResponse>): void;
102
+ removeFriend(friendId: string, onResponse?: Action1<RemoveFriendOperationResponse>): void;
103
+ getFriends(onResponse?: Action1<GetFriendsOperationResponse>): void;
104
+ findPlayer(keyword: string, skip?: number, limit?: number, onResponse?: Action1<FindPlayerOperationResponse>): void;
105
+ sendChatToUser(userId: string, message: string, saveToDatabase?: boolean, onResponse?: Action1<SendChatToUserOperationResponse>): void;
106
+ getChatMessageUser(userId: string, skip?: number, limit?: number, onResponse?: Action1<GetChatMessageUserOperationResponse>): void;
107
+ sendChatToChannel(channel: string, message: string, onResponse?: Action1<SendChatToChannelOperationResponse>): void;
108
+ joinChatChannel(channel: string, onResponse?: Action1<JoinChatChannelOperationResponse>): void;
109
+ leaveChatChannel(channel: string, onResponse?: Action1<LeaveChatChannelOperationResponse>): void;
110
+ getChatInfoChannel(channel: string, onResponse?: Action1<GetChatInfoChannelOperationResponse>): void;
111
+ getChatMessageChannel(channel: string, skip?: number, limit?: number, onResponse?: Action1<GetChatMessageChannelOperationResponse>): void;
112
+ getChatMemberChannel(channel: string, onResponse?: Action1<GetChatMemberChannelOperationResponse>): void;
113
+ editChatInfoChannel(channel: string, name?: string, avatarChannel?: GNHashtable, onResponse?: Action1<EditChatInfoChannelOperationResponse>): void;
114
+ editChatMessageChannel(tsCreate: number, channel: string, message?: string, isDelete?: boolean, onResponse?: Action1<EditChatMessageChannelOperationResponse>): void;
115
+ editChatMessageUser(tsCreate: number, userId: string, message?: string, isDelete?: boolean, onResponse?: Action1<EditChatMessageUserOperationResponse>): void;
74
116
  }
@@ -1,10 +1,13 @@
1
+ import { Action1 } from "./../common/Action1";
1
2
  import { Action0 } from "./../common/Action0";
2
3
  import { GNArray } from "./../common/GNData";
4
+ import { OperationEvent } from "./../entity/OperationEvent";
3
5
  import { IServerEventHandler } from "./handler/IServerEventHandler";
4
6
  import { OperationPending } from "./OperationPending";
5
7
  import { PeerBase } from "./PeerBase";
6
8
  export declare class SocketPeer extends PeerBase {
7
- private serverEventHandlerDic;
9
+ private serverEventHandlersDic;
10
+ private _onEventHandler;
8
11
  private networkingPeerBase;
9
12
  getClientId(): string;
10
13
  isConnected(): boolean;
@@ -18,6 +21,7 @@ export declare class SocketPeer extends PeerBase {
18
21
  removeOnDisconnectHandler(_onDisconnectHandler: Action0): void;
19
22
  connect(_onSocketConnect: Action0): void;
20
23
  disconnect(_onSocketDisconnect: Action0): void;
24
+ setOnEventHandler(_onEventHandler: Action1<OperationEvent>): void;
21
25
  send(operationPending: OperationPending): void;
22
26
  onEventHandler(obj: GNArray, isEncrypted: boolean): void;
23
27
  service(): void;
@@ -0,0 +1,6 @@
1
+ import { OperationEvent } from "./../../entity/OperationEvent";
2
+ import { IServerEventHandler } from "./IServerEventHandler";
3
+ export declare class OnChannelChatEventHandler implements IServerEventHandler {
4
+ getEventCode(): number;
5
+ handle(operationEvent: OperationEvent): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { OperationEvent } from "./../../entity/OperationEvent";
2
+ import { IServerEventHandler } from "./IServerEventHandler";
3
+ export declare class OnFriendUpdateEventHandler implements IServerEventHandler {
4
+ getEventCode(): number;
5
+ handle(operationEvent: OperationEvent): void;
6
+ }
@@ -0,0 +1,6 @@
1
+ import { OperationEvent } from "./../../entity/OperationEvent";
2
+ import { IServerEventHandler } from "./IServerEventHandler";
3
+ export declare class OnUserChatEventHandler implements IServerEventHandler {
4
+ getEventCode(): number;
5
+ handle(operationEvent: OperationEvent): void;
6
+ }
package/package.json CHANGED
@@ -1,37 +1,39 @@
1
- {
2
- "name": "@xmobitea/gn-typescript-client",
3
- "version": "0.0.4",
4
- "description": "",
5
- "types": "dist/index.d.ts",
6
- "main": "dist/index.js",
7
- "scripts": {
8
- "debug": "node index.js",
9
- "test": "mocha -r ts-node/register ./test/**/*.test.ts",
10
- "build": "rm -rf ./dist && webpack --mode production --display-modules",
11
- "push": "npm run build && npm run test && npm publish && git push"
12
- },
13
- "author": "changx.develop@gmail.com (https://xmobitea.com)",
14
- "license": "ISC",
15
- "devDependencies": {
16
- "@types/mocha": "^8.2.3",
17
- "@types/node-localstorage": "^1.3.0",
18
- "mocha": "^9.2.2",
19
- "terser-webpack-plugin": "^4.2.3",
20
- "ts-loader": "^8.4.0",
21
- "ts-node": "^10.9.1",
22
- "tslib": "^2.4.1",
23
- "webpack": "^5.75.0",
24
- "webpack-cli": "^3.3.12",
25
- "webpack-node-externals": "^3.0.0"
26
- },
27
- "dependencies": {
28
- "@msgpack/msgpack": "^2.8.0",
29
- "axios": "^1.2.2",
30
- "crypto": "^1.0.1",
31
- "node-localstorage": "^2.2.1",
32
- "socket.io-client": "^4.5.4"
33
- },
34
- "directories": {
35
- "test": "test"
36
- }
37
- }
1
+ {
2
+ "name": "@xmobitea/gn-typescript-client",
3
+ "version": "1.0.9",
4
+ "description": "",
5
+ "types": "dist/index.d.ts",
6
+ "main": "dist/index.js",
7
+ "scripts": {
8
+ "debug": "node index.js",
9
+ "test": "mocha -r ts-node/register ./test/**/*.test.ts",
10
+ "buildnode": "webpack --config webpack.config.js --mode production --display-modules",
11
+ "buildudm": "webpack --config webpack.config.udm.js --mode production --display-modules",
12
+ "build": "rm -rf ./dist && npm run buildnode && npm run buildudm",
13
+ "push": "npm run build && npm run test && npm publish && git push"
14
+ },
15
+ "author": "changx.develop@gmail.com (https://xmobitea.com)",
16
+ "license": "ISC",
17
+ "devDependencies": {
18
+ "@types/mocha": "^8.2.3",
19
+ "@types/store": "^2.0.2",
20
+ "mocha": "^9.2.2",
21
+ "terser-webpack-plugin": "^4.2.3",
22
+ "ts-loader": "^8.4.0",
23
+ "ts-node": "^10.9.1",
24
+ "tslib": "^2.4.1",
25
+ "webpack": "^5.75.0",
26
+ "webpack-cli": "^3.3.12",
27
+ "webpack-node-externals": "^3.0.0"
28
+ },
29
+ "dependencies": {
30
+ "@msgpack/msgpack": "^2.8.0",
31
+ "axios": "^1.2.2",
32
+ "reflect-metadata": "^0.1.13",
33
+ "socket.io-client": "^4.5.4",
34
+ "store": "^2.0.12"
35
+ },
36
+ "directories": {
37
+ "test": "test"
38
+ }
39
+ }