public App(AlloClient client, string appName) { this.client = client; this.appName = appName; client.onInteraction = this.routeInteraction; client.onDisconnected = this.clientWasDisconnected; client.onAdded = this.checkForAddedViewEntity; }
static unsafe private void _assetRequestBytes(_AlloClient *_client, IntPtr _assetId, UIntPtr offset, UIntPtr length) { GCHandle backref = (GCHandle)_client->_backref; AlloClient self = backref.Target as AlloClient; string assetId = Marshal.PtrToStringAnsi(_assetId); Debug.WriteLine($"Got request for asset {assetId}, length {length} at offset {offset}"); self.onAssetBytesRequested?.Invoke(assetId, (long)offset, (long)length); }
static unsafe private void _disconnected(_AlloClient *_client) { GCHandle backref = (GCHandle)_client->_backref; AlloClient self = backref.Target as AlloClient; Debug.WriteLine("_disconnected: calling delegate " + self.onDisconnected.ToString()); self.onDisconnected?.Invoke(); Debug.WriteLine("_disconnected: deallocating"); self.Disconnect(-1); }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jobject = JObject.Load(reader); string type = jobject["type"].ToString(); if (type == "box") { return(AlloClient.Deserialize <Component.BoxCollider>(jobject.ToString())); } Debug.Assert(false); return(null); }
static unsafe private void _interaction(_AlloClient *_client, _AlloInteraction *inter) { string type = Marshal.PtrToStringAnsi(inter->type); string from = Marshal.PtrToStringAnsi(inter->senderEntityId); string to = Marshal.PtrToStringAnsi(inter->receiverEntityId); string cmd = Marshal.PtrToStringAnsi(inter->body); string requestId = Marshal.PtrToStringAnsi(inter->requestId); GCHandle backref = (GCHandle)_client->_backref; AlloClient self = backref.Target as AlloClient; List <object> data = Deserialize <List <object> >(cmd); if (from == "place" && data[0].ToString() == "announce") { self.avatarId = data[1].ToString(); self.placeName = data[2].ToString(); self.connected = true; self.onConnected?.Invoke(); } AlloEntity fromEntity = null; if (!string.IsNullOrEmpty(from)) { self.entities.TryGetValue(from, out fromEntity); } AlloEntity toEntity = null; if (!string.IsNullOrEmpty(to)) { self.entities.TryGetValue(to, out toEntity); } ResponseCallback callback = null; if (type == "response" && !string.IsNullOrEmpty(requestId)) { self.responseCallbacks.TryGetValue(requestId, out callback); } if (callback != null) { callback(cmd); self.responseCallbacks.Remove(requestId); } else { self.onInteraction?.Invoke(type, fromEntity, toEntity, data); } }
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer) { JObject jobject = JObject.Load(reader); string geometryType = jobject["type"].ToString(); if (geometryType == "inline") { return(AlloClient.Deserialize <Component.InlineGeometry>(jobject.ToString())); } else if (geometryType == "asset") { return(AlloClient.Deserialize <Component.AssetGeometry>(jobject.ToString())); } else if (geometryType == "hardcoded-model") { return(AlloClient.Deserialize <Component.HardcodedGeometry>(jobject.ToString())); } Debug.Assert(false); return(null); }