Skip to content

Commit

Permalink
Update unitypackages at samples/Unity
Browse files Browse the repository at this point in the history
  • Loading branch information
veblush committed May 31, 2016
1 parent 343c3a5 commit ee9ba90
Show file tree
Hide file tree
Showing 47 changed files with 212 additions and 164 deletions.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Id": "AkkaInterfaced",
"Version": "0.2.1",
"Version": "0.3.1",
"Authors": [
"Esun Kim"
],
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Id": "AkkaInterfacedSlimSocket",
"Version": "0.2.2",
"Version": "0.3.1",
"Authors": [
"Esun Kim"
],
Expand All @@ -10,7 +10,7 @@
"Description": "SlimSocket-Client for Akka.Interfaced",
"Dependencies": {
"AkkaInterfaced": {
"Version": "0.2.*",
"Version": "0.3.*",
"Source": "github:SaladLab/Akka.Interfaced"
},
"CommonLogging": {
Expand All @@ -22,8 +22,8 @@
"Source": "github:SaladLab/NetLegacySupport"
},
"protobuf-net": {
"Version": "2.0.0.668",
"Source": "nuget:net20"
"Version": "2.1.0-alpha-1",
"Source": "nuget:net30"
},
"TypeAlias": {
"Version": "1.*",
Expand All @@ -32,7 +32,7 @@
},
"MergedDependencies": {
"AkkaInterfaced": {
"Version": "0.2.1"
"Version": "0.3.1"
},
"CommonLogging": {
"Version": "3.3.1"
Expand All @@ -41,7 +41,7 @@
"Version": "1.1.0"
},
"protobuf-net": {
"Version": "2.0.0.668"
"Version": "2.1.0-alpha-1"
},
"TypeAlias": {
"Version": "1.1.2"
Expand All @@ -52,8 +52,10 @@
"Assets/UnityPackages/AkkaInterfacedSlimSocket/Akka.Interfaced.SlimSocket.Base.dll.mdb",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/Akka.Interfaced.SlimSocket.Client.dll",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/Akka.Interfaced.SlimSocket.Client.dll.mdb",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/SlimRequestWaiter.cs",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/SlimTask.cs",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/CommunicatorHelper.cs",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/CommunicatorWorker.cs",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/SlimTaskCompletionSource.cs",
"Assets/UnityPackages/AkkaInterfacedSlimSocket/SlimTaskFactory.cs",
{
"Target": "Assets/UnityPackages/AkkaInterfaced.unitypackage.json",
"Merged": true
Expand Down Expand Up @@ -138,10 +140,6 @@
"Target": "Assets/UnityPackages/NetLegacySupport/NetLegacySupport.Tuple.dll",
"Merged": true
},
{
"Target": "Assets/UnityPackages/protobuf-net/protobuf-net.dll.mdb",
"Merged": true
},
{
"Target": "Assets/UnityPackages/protobuf-net/protobuf-net.dll",
"Merged": true
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
using System;
using System.Net;
using Akka.Interfaced.SlimSocket.Base;
using Common.Logging;
using ProtoBuf.Meta;
using TypeAlias;

namespace Akka.Interfaced.SlimSocket.Client
{
public static class CommunicatorHelper
{
public static PacketSerializer CreatePacketSerializer<TTypeModel>()
where TTypeModel : TypeModel, new()
{
return new PacketSerializer(
new PacketSerializerBase.Data(
new ProtoBufMessageSerializer(new TTypeModel()),
new TypeAliasTable()));
}

public static Communicator CreateCommunicator<TTypeModel>(ILog logger, IPEndPoint remoteEndPoint)
where TTypeModel : TypeModel, new()
{
var serializer = CreatePacketSerializer<TTypeModel>();
return CreateCommunicator(logger, remoteEndPoint, _ => new TcpConnection(serializer, logger));
}

public static Communicator CreateCommunicator(
ILog logger, IPEndPoint remoteEndPoint, Func<Communicator, TcpConnection> connectionFactory)
{
CommunicatorWorker.TryInit();

var comm = new Communicator(logger, remoteEndPoint, connectionFactory);
comm.TaskFactory = new SlimTaskFactory { Owner = CommunicatorWorker.Instance };
comm.ObserverEventPoster = c => CommunicatorWorker.Post(c, null);
return comm;
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
using System;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

namespace Akka.Interfaced.SlimSocket.Client
{
public class CommunicatorWorker : MonoBehaviour
{
private static CommunicatorWorker s_instance;
private static bool s_instanceExists;

private static readonly List<Tuple<SendOrPostCallback, object>> s_posts =
new List<Tuple<SendOrPostCallback, object>>();

public static CommunicatorWorker Instance
{
get { return s_instance; }
}

public static bool TryInit()
{
if (s_instanceExists)
return false;

s_instanceExists = true;

var go = new GameObject("_CommunicatorWorker");
s_instance = go.AddComponent<CommunicatorWorker>();
DontDestroyOnLoad(go);
return true;
}

public static void Post(SendOrPostCallback callback, object state)
{
lock (s_posts)
{
s_posts.Add(Tuple.Create(callback, state));
}
}

private void Awake()
{
if (s_instance)
{
DestroyImmediate(this);
}
else
{
s_instance = this;
s_instanceExists = true;
}
}

private void OnDestroy()
{
if (s_instance == this)
{
s_instance = null;
s_instanceExists = false;
}
}

private void Update()
{
lock (s_posts)
{
foreach (var post in s_posts)
{
post.Item1(post.Item2);
}
s_posts.Clear();
}
}
}
}

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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

namespace Akka.Interfaced.SlimSocket.Client
{
public class SlimTask<TResult> : Task<TResult>, ISlimTaskCompletionSource<TResult>
public class SlimTaskCompletionSource<TResult> : Task<TResult>, ISlimTaskCompletionSource<TResult>
{
internal MonoBehaviour Owner { get; set; }

Expand All @@ -26,7 +26,7 @@ private IEnumerator WaitForCompleted()

public TaskStatus Status
{
get; internal set;
get; private set;
}

public Exception Exception
Expand Down Expand Up @@ -70,8 +70,8 @@ public bool IsCompleted
get
{
return Status == TaskStatus.RanToCompletion ||
Status == TaskStatus.Canceled ||
Status == TaskStatus.Faulted;
Status == TaskStatus.Canceled ||
Status == TaskStatus.Faulted;
}
}

Expand All @@ -85,7 +85,7 @@ public bool IsFailed
get
{
return Status == TaskStatus.Canceled ||
Status == TaskStatus.Faulted;
Status == TaskStatus.Faulted;
}
}

Expand Down Expand Up @@ -119,5 +119,10 @@ public override string ToString()

return "Status: " + Status;
}

public Task<TResult> Task
{
get { return this; }
}
}
}
}

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using UnityEngine;

namespace Akka.Interfaced.SlimSocket.Client
{
public class SlimTaskFactory : ISlimTaskFactory
{
internal MonoBehaviour Owner { get; set; }

public ISlimTaskCompletionSource<TResult> Create<TResult>()
{
return new SlimTaskCompletionSource<TResult> { Owner = Owner };
}
}
}

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

Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"Id": "EntityNetwork",
"Version": "0.2.0",
"Version": "0.2.1",
"Authors": [
"Esun Kim"
],
Expand All @@ -14,8 +14,8 @@
"Source": "github:SaladLab/NetLegacySupport"
},
"protobuf-net": {
"Version": "2.0.0.668",
"Source": "nuget:net20"
"Version": "2.1.0-alpha-1",
"Source": "nuget:net30"
},
"TrackableData": {
"Version": "1.*",
Expand All @@ -27,10 +27,10 @@
"Version": "1.1.0"
},
"protobuf-net": {
"Version": "2.0.0.668"
"Version": "2.1.0-alpha-1"
},
"TrackableData": {
"Version": "1.1.0"
"Version": "1.1.1"
},
"JsonNet": {
"Version": "8.0.3"
Expand Down Expand Up @@ -94,10 +94,6 @@
"Target": "Assets/UnityPackages/NetLegacySupport/NetLegacySupport.Tuple.dll",
"Merged": true
},
{
"Target": "Assets/UnityPackages/protobuf-net/protobuf-net.dll.mdb",
"Merged": true
},
{
"Target": "Assets/UnityPackages/protobuf-net/protobuf-net.dll",
"Merged": true
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit ee9ba90

Please sign in to comment.