Initial Client/Server Communication
#1 Followed the MagicOnion quickstart guide, borrowing code from the chat sample app to get something working
This commit is contained in:
parent
52b0d4d8ff
commit
a0c8dbee72
493 changed files with 57790 additions and 3 deletions
15
Assets/Scripts/ServerShared/ChatApp.Shared.Unity.asmdef
Normal file
15
Assets/Scripts/ServerShared/ChatApp.Shared.Unity.asmdef
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"name": "ChatApp.Shared.Unity",
|
||||
"references": [
|
||||
"MessagePack",
|
||||
"MagicOnion.Abstractions"
|
||||
],
|
||||
"optionalUnityReferences": [],
|
||||
"includePlatforms": [],
|
||||
"excludePlatforms": [],
|
||||
"allowUnsafeCode": false,
|
||||
"overrideReferences": false,
|
||||
"precompiledReferences": [],
|
||||
"autoReferenced": true,
|
||||
"defineConstraints": []
|
||||
}
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 6c33754198bab0b49a95ca89f14de1a5
|
||||
AssemblyDefinitionImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ServerShared/Hubs.meta
Normal file
8
Assets/Scripts/ServerShared/Hubs.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2e0485c6f6dee60498657a6f1f50ea69
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
25
Assets/Scripts/ServerShared/Hubs/IChatHub.cs
Normal file
25
Assets/Scripts/ServerShared/Hubs/IChatHub.cs
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
using ChatApp.Shared.MessagePackObjects;
|
||||
using MagicOnion;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace ChatApp.Shared.Hubs
|
||||
{
|
||||
/// <summary>
|
||||
/// Client -> Server API (Streaming)
|
||||
/// </summary>
|
||||
public interface IChatHub : IStreamingHub<IChatHub, IChatHubReceiver>
|
||||
{
|
||||
Task JoinAsync(JoinRequest request);
|
||||
|
||||
Task LeaveAsync();
|
||||
|
||||
Task SendMessageAsync(string message);
|
||||
|
||||
Task GenerateException(string message);
|
||||
|
||||
// It is not called because it is a method as a sample of arguments.
|
||||
Task SampleMethod(List<int> sampleList, Dictionary<int, string> sampleDictionary);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Hubs/IChatHub.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Hubs/IChatHub.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 2080c15c13ba0c14aa0682bec9550f33
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/ServerShared/Hubs/IChatHubReceiver.cs
Normal file
16
Assets/Scripts/ServerShared/Hubs/IChatHubReceiver.cs
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
using ChatApp.Shared.MessagePackObjects;
|
||||
|
||||
namespace ChatApp.Shared.Hubs
|
||||
{
|
||||
/// <summary>
|
||||
/// Server -> Client API
|
||||
/// </summary>
|
||||
public interface IChatHubReceiver
|
||||
{
|
||||
void OnJoin(string name);
|
||||
|
||||
void OnLeave(string name);
|
||||
|
||||
void OnSendMessage(MessageResponse message);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Hubs/IChatHubReceiver.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Hubs/IChatHubReceiver.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4857e2640847cd94f90257e00ec6854f
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ServerShared/MessagePackObjects.meta
Normal file
8
Assets/Scripts/ServerShared/MessagePackObjects.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 3dfb982d047b6c348836f49863993e1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/ServerShared/MessagePackObjects/Requests.cs
Normal file
17
Assets/Scripts/ServerShared/MessagePackObjects/Requests.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using MessagePack;
|
||||
|
||||
namespace ChatApp.Shared.MessagePackObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Room participation information
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct JoinRequest
|
||||
{
|
||||
[Key(0)]
|
||||
public string RoomName { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public string UserName { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 00baa3467159d704dae9afbac3f4729b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
17
Assets/Scripts/ServerShared/MessagePackObjects/Responses.cs
Normal file
17
Assets/Scripts/ServerShared/MessagePackObjects/Responses.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
using MessagePack;
|
||||
|
||||
namespace ChatApp.Shared.MessagePackObjects
|
||||
{
|
||||
/// <summary>
|
||||
/// Message information
|
||||
/// </summary>
|
||||
[MessagePackObject]
|
||||
public struct MessageResponse
|
||||
{
|
||||
[Key(0)]
|
||||
public string UserName { get; set; }
|
||||
|
||||
[Key(1)]
|
||||
public string Message { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: ba2df8e833f170640b371a83db3df1ef
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
8
Assets/Scripts/ServerShared/Services.meta
Normal file
8
Assets/Scripts/ServerShared/Services.meta
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
fileFormatVersion: 2
|
||||
guid: fab80ed56c97e934c9e7a836f31caa64
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/ServerShared/Services/IChatService.cs
Normal file
14
Assets/Scripts/ServerShared/Services/IChatService.cs
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
using MagicOnion;
|
||||
using MessagePack;
|
||||
|
||||
namespace ChatApp.Shared.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Client -> Server API
|
||||
/// </summary>
|
||||
public interface IChatService : IService<IChatService>
|
||||
{
|
||||
UnaryResult<Nil> GenerateException(string message);
|
||||
UnaryResult<Nil> SendReportAsync(string message);
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/ServerShared/Services/IChatService.cs.meta
Normal file
11
Assets/Scripts/ServerShared/Services/IChatService.cs.meta
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 1319521a7dd3e5048b28683232e79387
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Loading…
Reference in a new issue