public void syncPosition(long gameId, string objectName, int objectType, int objectId, bool visible, double x, double y, double z ) { if (!appAccessed) { return; } var position = EzyEntityFactory.newObject(); position.put("x", x); position.put("y", y); position.put("z", z); var request = EzyEntityFactory.newObject(); request.put("gameName", GAME_NAME); request.put("gameId", gameId); request.put("objectId", objectId); request.put("objectName", objectName); request.put("objectType", objectType); request.put("visible", visible); request.put("position", position); var app = socketClient.getApp(); if (app != null) { app.udpSend("syncPosition", request); } }
protected override void postHandle(EzyApp app, EzyArray data) { var request = EzyEntityFactory.newObject(); request.put("gameName", SocketClientProxy.GAME_NAME); app.send("reconnect", request); }
public void getGameId() { var request = EzyEntityFactory.newObject(); request.put("gameName", GAME_NAME); socketClient.getApp().send("getGameId", request); }
protected override EzyObject objectToMap(T obj, EzyMarshaller marshaller) { EzyObject map = EzyEntityFactory.newObject(); foreach (PropertyInfo property in objectType.GetProperties()) { string key = null; EzyValue anno = property.GetCustomAttribute <EzyValue>(); if (anno != null) { key = anno.name; } else { key = property.Name.Length <= 1 ? char.ToLower(property.Name[0]).ToString() : char.ToLower(property.Name[0]) + property.Name.Substring(1); } object rawValue = property.GetValue(obj); object value = rawValue != null?marshaller.marshall <object>(rawValue) : null; map.put(key, value); } return(map); }
public void finishGame(long gameId) { var request = EzyEntityFactory.newObject(); request.put("gameName", GAME_NAME); request.put("gameId", gameId); socketClient.getApp().send("finishGame", request); }
public void deleteGameObject(long gameId, int objectId) { var request = EzyEntityFactory.newObject(); request.put("gameName", GAME_NAME); request.put("gameId", gameId); request.put("objectId", objectId); socketClient.getApp().send("deleteGameObject", request); }
public void syncScore(long gameId, long score) { var request = EzyEntityFactory.newObject(); request.put("gameName", GAME_NAME); request.put("gameId", gameId); request.put("score", score); socketClient.getApp().send("updateScore", request); }
public object marshallByInType(object input, Type inType) { if (input == null) { return(null); } if (writerByInType.ContainsKey(inType)) { IEzyWriter writer = writerByInType[inType]; return(writer.write(input, this)); } if (typeof(IDictionary).IsAssignableFrom(inType)) { EzyObject answer = EzyEntityFactory.newObject(); IDictionary dict = (IDictionary)(input); Type keyType = inType.GetGenericArguments()[0]; Type valueType = inType.GetGenericArguments()[1]; foreach (DictionaryEntry entry in dict) { answer.put( marshallByInType(entry.Key, keyType), marshallByInType(entry.Value, valueType)); } return(answer); } else if (typeof(IList).IsAssignableFrom(inType)) { EzyArray answer = EzyEntityFactory.newArray(); IList list = (IList)(input); Type valueType = inType.GetGenericArguments()[0]; foreach (Object value in list) { answer.add(marshallByInType(value, valueType)); } return(answer); } return(input); }
protected Object transformNonNullValue(Object value) { if (value is IDictionary) { IDictionary dictionary = (IDictionary)value; EzyObject obj = EzyEntityFactory.newObject(); foreach (DictionaryEntry entry in dictionary) { obj.put(transform(entry.Key), transform(entry.Value)); } return(obj); } if (value is ICollection) { IEnumerable collection = (IEnumerable)value; EzyArray array = EzyEntityFactory.newArray(); foreach (Object item in collection) { array.add(transform(item)); } return(array); } return(value); }