Skip to content

Commit

Permalink
Support for Unity2019
Browse files Browse the repository at this point in the history
  • Loading branch information
OnestarLee committed Feb 29, 2024
1 parent 9c32bf8 commit 9305c8d
Show file tree
Hide file tree
Showing 11 changed files with 47 additions and 69 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,9 @@ void OnTranslateUserMessageCompletionHandler(ApiCommandAbstract.Response inRespo

private SbPreviousMessageListQuery CreatePreviousMessageListQueryInternal(SbPreviousMessageListQueryParams inParams = null)
{
inParams ??= new SbPreviousMessageListQueryParams();
if (inParams == null)
inParams = new SbPreviousMessageListQueryParams();

return new SbPreviousMessageListQuery(ChannelType, _url, inParams, chatMainContextRef);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,17 @@ void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError

private SbBannedUserListQuery CreateBannedUserListQueryInternal(SbBannedUserListQueryParams inParams = null)
{
inParams ??= new SbBannedUserListQueryParams();
if (inParams == null)
inParams = new SbBannedUserListQueryParams();

return new SbBannedUserListQuery(ChannelType, _url, inParams, chatMainContextRef);
}

private SbMutedUserListQuery CreateMutedUserListQueryInternal(SbMutedUserListQueryParams inParams = null)
{
inParams ??= new SbMutedUserListQueryParams();
if (inParams == null)
inParams = new SbMutedUserListQueryParams();

return new SbMutedUserListQuery(ChannelType, _url, inParams, chatMainContextRef);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,9 @@ void OnCompletionHandler(ApiCommandAbstract.Response inResponse, SbError inError

private SbOperatorListQuery CreateOperatorListQueryInternal(SbOperatorListQueryParams inParams = null)
{
inParams ??= new SbOperatorListQueryParams();
if (inParams == null)
inParams = new SbOperatorListQueryParams();

return new SbOperatorListQuery(ChannelType, _url, inParams, chatMainContextRef);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal void Initialize(SbInitParams inInitParams)
{
if (_isTerminated == false)
Terminate();

ChatMainContext.Initialize(SendbirdChatMainContext.SDK_VERSION, SendbirdChatMainContext.PLATFORM_NAME, SendbirdChatMainContext.PLATFORM_VERSION,
SendbirdChatMainContext.OS_NAME, SendbirdChatMainContext.OS_VERSION, inInitParams.ApplicationId, inInitParams.AppVersion);

Expand Down Expand Up @@ -128,19 +128,25 @@ internal void SetSessionHandler(SbSessionHandler inSessionHandler)

internal SbApplicationUserListQuery CreateApplicationUserListQuery(SbApplicationUserListQueryParams inParams = null)
{
inParams ??= new SbApplicationUserListQueryParams();
if (inParams == null)
inParams = new SbApplicationUserListQueryParams();

return new SbApplicationUserListQuery(inParams, ChatMainContext);
}

internal SbBlockedUserListQuery CreateBlockedUserListQuery(SbBlockedUserListQueryParams inParams = null)
{
inParams ??= new SbBlockedUserListQueryParams();
if (inParams == null)
inParams = new SbBlockedUserListQueryParams();

return new SbBlockedUserListQuery(inParams, ChatMainContext);
}

public SbMessageSearchQuery CreateMessageSearchQuery(SbMessageSearchQueryParams inParams = null)
{
inParams ??= new SbMessageSearchQueryParams();
if (inParams == null)
inParams = new SbMessageSearchQueryParams();

return new SbMessageSearchQuery(inParams, ChatMainContext);
}
}
Expand Down
35 changes: 19 additions & 16 deletions Runtime/Scripts/Internal/Network/Client/WsClient/WsClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -331,20 +331,11 @@ private async void WaitingForReceiveAsync()
{
Logger.Info(Logger.CategoryType.WebSocket, "WsClient::WaitingForReceiveAsync start");

void DispatchReceiveErrorOnNextFrame(WsClientErrorType inClientReceiveErrorType, WsClientError inWsClientErrorNullable = null)
{
Logger.Warning(Logger.CategoryType.WebSocket, $"WsClient::DispatchReceiveErrorOnNextFrame ErrorType:{inClientReceiveErrorType}");
if (_eventListeners != null)
{
CoroutineManager.Instance.CallOnNextFrame(() => { _eventListeners.OnErrorInOpenState(inClientReceiveErrorType, inWsClientErrorNullable); });
}
}

ArraySegment<byte> buffer = WebSocket.CreateClientBuffer(1024, 1024);
if (buffer.Array == null)
{
Logger.Error(Logger.CategoryType.WebSocket, "WsClient::WaitingForReceiveAsync buffer.Array is null");
DispatchReceiveErrorOnNextFrame(WsClientErrorType.CreateReceiveBufferFailed);
OnDispatchReceiveErrorOnNextFrame(WsClientErrorType.CreateReceiveBufferFailed);
return;
}

Expand Down Expand Up @@ -402,12 +393,14 @@ void DispatchReceiveErrorOnNextFrame(WsClientErrorType inClientReceiveErrorType,

if (webSocketReceiveResult.MessageType == WebSocketMessageType.Text)
{
using StreamReader streamReader = new StreamReader(memoryStream, Encoding.UTF8);
Task<string> readToEndTask = streamReader.ReadToEndAsync();
await readToEndTask;
using (StreamReader streamReader = new StreamReader(memoryStream, Encoding.UTF8))
{
Task<string> readToEndTask = streamReader.ReadToEndAsync();
await readToEndTask;

Logger.Info(Logger.CategoryType.WebSocket, $"WsClient::Receive {readToEndTask.Result}");
_receiveQueue.Add(readToEndTask.Result);
Logger.Info(Logger.CategoryType.WebSocket, $"WsClient::Receive {readToEndTask.Result}");
_receiveQueue.Add(readToEndTask.Result);
}
}
else if (webSocketReceiveResult.MessageType == WebSocketMessageType.Close)
{
Expand All @@ -427,7 +420,17 @@ void DispatchReceiveErrorOnNextFrame(WsClientErrorType inClientReceiveErrorType,
Logger.Info(Logger.CategoryType.WebSocket, "WsClient::WaitForReceiveAsync end");

if( isForcedClose == false)
DispatchReceiveErrorOnNextFrame(wsClientErrorType, wsClientError);
OnDispatchReceiveErrorOnNextFrame(wsClientErrorType, wsClientError);

return;
void OnDispatchReceiveErrorOnNextFrame(WsClientErrorType inClientReceiveErrorType, WsClientError inWsClientErrorNullable = null)
{
Logger.Warning(Logger.CategoryType.WebSocket, $"WsClient::DispatchReceiveErrorOnNextFrame ErrorType:{inClientReceiveErrorType}");
if (_eventListeners != null)
{
CoroutineManager.Instance.CallOnNextFrame(() => { _eventListeners.OnErrorInOpenState(inClientReceiveErrorType, inWsClientErrorNullable); });
}
}
}
}
}
8 changes: 0 additions & 8 deletions Runtime/ThirdParty/NewtonsoftJson.meta

This file was deleted.

Binary file not shown.
33 changes: 0 additions & 33 deletions Runtime/ThirdParty/NewtonsoftJson/Newtonsoft.Json.dll.meta

This file was deleted.

1 change: 1 addition & 0 deletions SendbirdLink.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
<linker>
<assembly fullname="Sendbird.Chat" preserve="all"/>
<assembly fullname="System.Web" preserve="all"/>
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions.Interpreter.LightLambda" preserve="all" />
</assembly>
Expand Down
5 changes: 2 additions & 3 deletions Runtime/ThirdParty.meta → catalog-info.yaml.meta

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

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
"changelogUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/CHANGELOG.md",
"licensesUrl": "https://github.com/sendbird/sendbird-chat-sdk-unity/blob/master/LICENSE.md",
"description": "The Sendbird Chat SDK for Unity allows you to add real-time chat into your client app with minimal effort. Sendbird offers a feature rich, scalable, and proven chat solution depended on by companies like Reddit, Hinge, PubG and Paytm.",
"dependencies": { },
"dependencies": {
"com.unity.nuget.newtonsoft-json": "2.0.0"
},
"keywords": [
"sendbird",
"chat"
Expand Down

0 comments on commit 9305c8d

Please sign in to comment.