Skip to content

Commit 6c9ff8f

Browse files
authored
release 4.0.0
1 parent d74e1a9 commit 6c9ff8f

File tree

809 files changed

+3071
-2354
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

809 files changed

+3071
-2354
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: Approve by automation
2+
3+
on:
4+
pull_request:
5+
types: [opened, reopened]
6+
jobs:
7+
approve-pull-request:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@v4
11+
- name: 'approve a pull request'
12+
env:
13+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
14+
run: |
15+
gh pr review ${{ github.event.pull_request.number }} --approve --body "approved by automation"

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# Change Log
22

3+
## 4.0.0 (Sep 25, 2024)
4+
### Features
5+
- Added support for WebGL
6+
37
## 4.0.0-beta.3 (Apr 9, 2024)
48
### Improvements
59
- Added SendbirdChatPrivacyInfo.xcprivacy for Apple Privacy Manifest

Runtime/Plugins/WebGL.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 142 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,142 @@
1+
const SendbirdWebSocketBridge = {
2+
$bridgeContext: {
3+
clients: {},
4+
clientIdCounter: 0,
5+
onOpenCallback: null,
6+
onMessageCallback: null,
7+
onErrorCallback: null,
8+
onCloseCallback: null,
9+
invokeOnOpenCallback: function (clientId) {
10+
if (bridgeContext.onOpenCallback) {
11+
Module.dynCall_vi(bridgeContext.onOpenCallback, clientId);
12+
}
13+
},
14+
15+
invokeOnMessageCallback: function (clientId, stringPtr) {
16+
if (bridgeContext.onMessageCallback) {
17+
Module.dynCall_vii(bridgeContext.onMessageCallback, clientId, stringPtr);
18+
}
19+
},
20+
21+
invokeOnErrorCallback: function (clientId) {
22+
if (bridgeContext.onErrorCallback) {
23+
Module.dynCall_vi(bridgeContext.onErrorCallback, clientId);
24+
}
25+
},
26+
27+
invokeOnCloseCallback: function (clientId) {
28+
if (bridgeContext.onCloseCallback) {
29+
Module.dynCall_vi(bridgeContext.onCloseCallback, clientId);
30+
}
31+
},
32+
},
33+
34+
SendbirdWebSocketBridge_RegisterCallbacks: function (onOpen, onMessage, onError, onClose) {
35+
bridgeContext.onOpenCallback = onOpen;
36+
bridgeContext.onMessageCallback = onMessage;
37+
bridgeContext.onErrorCallback = onError;
38+
bridgeContext.onCloseCallback = onClose;
39+
},
40+
41+
// Create a new WebSocket client and return its unique ID
42+
SendbirdWebSocketBridge_CreateWebSocketClient: function () {
43+
if (bridgeContext.clientIdCounter >= Number.MAX_SAFE_INTEGER) {
44+
bridgeContext.clientIdCounter = 0;
45+
}
46+
47+
const clientId = bridgeContext.clientIdCounter++;
48+
bridgeContext.clients[clientId] = {
49+
clientId: clientId,
50+
webSocket: null
51+
};
52+
return clientId;
53+
},
54+
55+
// Delete the WebSocket client by ID
56+
SendbirdWebSocketBridge_DeleteWebSocketClient: function (clientId) {
57+
if (bridgeContext.clients[clientId] != null) {
58+
delete bridgeContext.clients[clientId];
59+
} else {
60+
console.warn('DeleteWebSocketClient WebSocket client not found with ID: ' + clientId);
61+
}
62+
},
63+
64+
SendbirdWebSocketBridge_Connect: function (clientId, uriStringPtr, encodedProtocolsStringPtr) {
65+
const client = bridgeContext.clients[clientId];
66+
if (!client) {
67+
console.error('SendbirdWebSocketBridge_Connect client not found with ID: ' + clientId);
68+
bridgeContext.invokeOnErrorCallback(clientId);
69+
return;
70+
}
71+
72+
if (client.webSocket != null && client.webSocket.readyState === WebSocket.OPEN) {
73+
console.warn('WebSocket is already connected.');
74+
return;
75+
}
76+
77+
console.warn('SendbirdWebSocketBridge_Connect protocols: ' + UTF8ToString(encodedProtocolsStringPtr));
78+
client.webSocket = new WebSocket(UTF8ToString(uriStringPtr), UTF8ToString(encodedProtocolsStringPtr));
79+
80+
client.webSocket.onopen = () => {
81+
console.log('WebSocket connection opened for client: ' + client.clientId);
82+
bridgeContext.invokeOnOpenCallback(client.clientId);
83+
};
84+
85+
client.webSocket.onmessage = (event) => {
86+
console.log('WebSocket message received: ', event.data);
87+
if (typeof event.data === 'string') {
88+
var lengthBytes = lengthBytesUTF8(event.data) + 1;
89+
var stringPtr = _malloc(lengthBytes);
90+
stringToUTF8(event.data, stringPtr, lengthBytes);
91+
bridgeContext.invokeOnMessageCallback(client.clientId, stringPtr);
92+
} else {
93+
console.warn("WebSocket received invalid message type:", (typeof event.data));
94+
}
95+
};
96+
97+
client.webSocket.onerror = () => {
98+
console.error('WebSocket error for client: ' + client.clientId);
99+
bridgeContext.invokeOnErrorCallback(client.clientId);
100+
};
101+
102+
client.webSocket.onclose = () => {
103+
console.log('WebSocket connection closed for client: ' + client.clientId);
104+
bridgeContext.invokeOnCloseCallback(client.clientId);
105+
};
106+
},
107+
108+
SendbirdWebSocketBridge_Send: function (clientId, messageStringPtr) {
109+
const client = bridgeContext.clients[clientId];
110+
if (!client) {
111+
bridgeContext.invokeOnErrorCallback(clientId);
112+
console.error('SendbirdWebSocketBridge_Send client not found with ID: ' + clientId);
113+
return;
114+
}
115+
116+
if (client.webSocket != null && client.webSocket.readyState === WebSocket.OPEN) {
117+
client.webSocket.send(UTF8ToString(messageStringPtr));
118+
} else {
119+
console.error('WebSocket is not open. Cannot send message for client: ' + client.clientId);
120+
bridgeContext.invokeOnErrorCallback(clientId);
121+
}
122+
},
123+
124+
SendbirdWebSocketBridge_Close: function (clientId) {
125+
const client = bridgeContext.clients[clientId];
126+
if (!client) {
127+
console.warn('SendbirdWebSocketBridge_Send client not found with ID: ' + clientId);
128+
bridgeContext.invokeOnErrorCallback(clientId);
129+
return;
130+
}
131+
132+
if (client.webSocket != null && client.webSocket.readyState !== WebSocket.CLOSING && client.webSocket.readyState !== WebSocket.CLOSED) {
133+
client.webSocket.Close();
134+
} else {
135+
console.warn('Close WebSocket client not found with ID: ' + clientId);
136+
bridgeContext.invokeOnErrorCallback(clientId);
137+
}
138+
},
139+
};
140+
141+
autoAddDeps(SendbirdWebSocketBridge, '$bridgeContext');
142+
mergeInto(LibraryManager.library, SendbirdWebSocketBridge);

Runtime/Plugins/WebGL/SendbirdWebSocket.jslib.meta

Lines changed: 3 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Internal.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Internal/ChatClient.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Internal/ChatClient/Channel.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Internal/ChatClient/Channel/BaseChannel.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Scripts/Internal/ChatClient/Channel/BaseChannel/SbBaseChannel+BaseMessage.cs.meta

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)