Skip to content

Commit

Permalink
release 4.0.0
Browse files Browse the repository at this point in the history
  • Loading branch information
OnestarLee authored Sep 25, 2024
1 parent d74e1a9 commit 6c9ff8f
Show file tree
Hide file tree
Showing 809 changed files with 3,071 additions and 2,354 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/BuildAutomation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
name: Approve by automation

on:
pull_request:
types: [opened, reopened]
jobs:
approve-pull-request:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: 'approve a pull request'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh pr review ${{ github.event.pull_request.number }} --approve --body "approved by automation"
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Change Log

## 4.0.0 (Sep 25, 2024)
### Features
- Added support for WebGL

## 4.0.0-beta.3 (Apr 9, 2024)
### Improvements
- Added SendbirdChatPrivacyInfo.xcprivacy for Apple Privacy Manifest
Expand Down
3 changes: 3 additions & 0 deletions Runtime/Plugins/WebGL.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

142 changes: 142 additions & 0 deletions Runtime/Plugins/WebGL/SendbirdWebSocket.jslib
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
const SendbirdWebSocketBridge = {
$bridgeContext: {
clients: {},
clientIdCounter: 0,
onOpenCallback: null,
onMessageCallback: null,
onErrorCallback: null,
onCloseCallback: null,
invokeOnOpenCallback: function (clientId) {
if (bridgeContext.onOpenCallback) {
Module.dynCall_vi(bridgeContext.onOpenCallback, clientId);
}
},

invokeOnMessageCallback: function (clientId, stringPtr) {
if (bridgeContext.onMessageCallback) {
Module.dynCall_vii(bridgeContext.onMessageCallback, clientId, stringPtr);
}
},

invokeOnErrorCallback: function (clientId) {
if (bridgeContext.onErrorCallback) {
Module.dynCall_vi(bridgeContext.onErrorCallback, clientId);
}
},

invokeOnCloseCallback: function (clientId) {
if (bridgeContext.onCloseCallback) {
Module.dynCall_vi(bridgeContext.onCloseCallback, clientId);
}
},
},

SendbirdWebSocketBridge_RegisterCallbacks: function (onOpen, onMessage, onError, onClose) {
bridgeContext.onOpenCallback = onOpen;
bridgeContext.onMessageCallback = onMessage;
bridgeContext.onErrorCallback = onError;
bridgeContext.onCloseCallback = onClose;
},

// Create a new WebSocket client and return its unique ID
SendbirdWebSocketBridge_CreateWebSocketClient: function () {
if (bridgeContext.clientIdCounter >= Number.MAX_SAFE_INTEGER) {
bridgeContext.clientIdCounter = 0;
}

const clientId = bridgeContext.clientIdCounter++;
bridgeContext.clients[clientId] = {
clientId: clientId,
webSocket: null
};
return clientId;
},

// Delete the WebSocket client by ID
SendbirdWebSocketBridge_DeleteWebSocketClient: function (clientId) {
if (bridgeContext.clients[clientId] != null) {
delete bridgeContext.clients[clientId];
} else {
console.warn('DeleteWebSocketClient WebSocket client not found with ID: ' + clientId);
}
},

SendbirdWebSocketBridge_Connect: function (clientId, uriStringPtr, encodedProtocolsStringPtr) {
const client = bridgeContext.clients[clientId];
if (!client) {
console.error('SendbirdWebSocketBridge_Connect client not found with ID: ' + clientId);
bridgeContext.invokeOnErrorCallback(clientId);
return;
}

if (client.webSocket != null && client.webSocket.readyState === WebSocket.OPEN) {
console.warn('WebSocket is already connected.');
return;
}

console.warn('SendbirdWebSocketBridge_Connect protocols: ' + UTF8ToString(encodedProtocolsStringPtr));
client.webSocket = new WebSocket(UTF8ToString(uriStringPtr), UTF8ToString(encodedProtocolsStringPtr));

client.webSocket.onopen = () => {
console.log('WebSocket connection opened for client: ' + client.clientId);
bridgeContext.invokeOnOpenCallback(client.clientId);
};

client.webSocket.onmessage = (event) => {
console.log('WebSocket message received: ', event.data);
if (typeof event.data === 'string') {
var lengthBytes = lengthBytesUTF8(event.data) + 1;
var stringPtr = _malloc(lengthBytes);
stringToUTF8(event.data, stringPtr, lengthBytes);
bridgeContext.invokeOnMessageCallback(client.clientId, stringPtr);
} else {
console.warn("WebSocket received invalid message type:", (typeof event.data));
}
};

client.webSocket.onerror = () => {
console.error('WebSocket error for client: ' + client.clientId);
bridgeContext.invokeOnErrorCallback(client.clientId);
};

client.webSocket.onclose = () => {
console.log('WebSocket connection closed for client: ' + client.clientId);
bridgeContext.invokeOnCloseCallback(client.clientId);
};
},

SendbirdWebSocketBridge_Send: function (clientId, messageStringPtr) {
const client = bridgeContext.clients[clientId];
if (!client) {
bridgeContext.invokeOnErrorCallback(clientId);
console.error('SendbirdWebSocketBridge_Send client not found with ID: ' + clientId);
return;
}

if (client.webSocket != null && client.webSocket.readyState === WebSocket.OPEN) {
client.webSocket.send(UTF8ToString(messageStringPtr));
} else {
console.error('WebSocket is not open. Cannot send message for client: ' + client.clientId);
bridgeContext.invokeOnErrorCallback(clientId);
}
},

SendbirdWebSocketBridge_Close: function (clientId) {
const client = bridgeContext.clients[clientId];
if (!client) {
console.warn('SendbirdWebSocketBridge_Send client not found with ID: ' + clientId);
bridgeContext.invokeOnErrorCallback(clientId);
return;
}

if (client.webSocket != null && client.webSocket.readyState !== WebSocket.CLOSING && client.webSocket.readyState !== WebSocket.CLOSED) {
client.webSocket.Close();
} else {
console.warn('Close WebSocket client not found with ID: ' + clientId);
bridgeContext.invokeOnErrorCallback(clientId);
}
},
};

autoAddDeps(SendbirdWebSocketBridge, '$bridgeContext');
mergeInto(LibraryManager.library, SendbirdWebSocketBridge);
3 changes: 3 additions & 0 deletions Runtime/Plugins/WebGL/SendbirdWebSocket.jslib.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Runtime/Scripts/Internal.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Runtime/Scripts/Internal/ChatClient.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Runtime/Scripts/Internal/ChatClient/Channel.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Runtime/Scripts/Internal/ChatClient/Channel/BaseChannel.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6c9ff8f

Please sign in to comment.