Just started coding with Appwarps and I'm running into an issue. I have a lobby built that shows live rooms, but I really do not want to show the rooms for matches that have already started. I figured I would use
void Client::setCustomRoomData(std::string roomId, std::string customData)
But I have some doubts on how to use it. Once the game starts, I plan on sending
SetCustomRoomData(roomId, "Closed");
to notify the server that open seating is now closed. However, when I check the room properties on another device when it calls
void CCAppwarpDelegate::onGetLiveRoomInfoDone(AppWarp::liveroom revent)
{
CCLog("CustomData=%s",revent.customData.c_str());
...
it returns blank. What am I missing here? Besides the code not working, what really makes me question myself is that I don't understand the mechanics of the properties. How do you have multiple custom properties since you aren't assigning it any kind of index...or do room only have a single custom property at any given time?
You don't need to use customData and instead use only room properties. Room properties is a set of key/value pairs that you can associate with a room.
I recommend you read the following link
http://appwarp.shephertz.com/game-development-center/matchmaking-basic-concept/
So the flow is as follows -
you first create the room using the createRoom API and pass a
properties dictionary containing <"closed", "false">.
Then once the game is active, you use updateRoomProperties API
on the room and pass <"closed", "true"> to the API.
Then when you want to show the list you should use
getRoomWithProperties and pass <"closed", "false">. This will get
you a list of rooms that are not yet "closed".
Related
I'm using the World of warcraft API. And I want to find an EventMessageFilter. I can do so by calling
ChatFrame_GetMessageEventFilters("event")
And to do this I have to pass a chat event, in my case CHAT_MSG_WHISPER_INFORM.
So according to the API located over at
http://wowprogramming.com/docs/api/ChatFrame_GetMessageEventFilters
This function will return a table. So I named the table and tried to print its content with this code
local myNewTable = filterTable = ChatFrame_GetMessageEventFilters("CHAT_MSG_WHISPER_INFORM")
for i in pairs(myNewTable) do
print(asd[i])
end
And this then prints out something like
function: 00000312498vn27842934c4
I have checked with
type(asd[i])
and it really is a function. But how can I get the content of it? How do I handle it?
I want to find an EventMessageFilter
Can you elaborate? Whose filter are you looking for and what do you intend to do with it?
it really is a function.
That's what this API does: returns a list of functions that are registered as filters for a particular message type (via ChatFrame_AddMessageEventFilter).
But how can I get the content of it?
You can't. The WoW API doesn't offer you any facilities for decompiling functions.
If your intention is to filter chat messages yourself, you don't need to call this function at all. Just call ChatFrame_AddMessageEventFilter to add your filter.
So I managed to solve my problem by removing to current filters that have been put in place by another addon and then just add my own filter. As Mud pointed out. GMEF was supposed to return functions. I now see how this makes sense. But now I have made the code to remove the functions. If you want to re-add them later on, just store them in a variable until you are done but I won't include this in my answer. I also feel like my answer is kinda half off-topic ish. But to answer my own question. It is supposed to return functions and you can't see the contents of these functions. This is the code I used to remove the functions that were put in there by another addon.
function rekkFilters()
local myFilters = ChatFrame_GetMessageEventFilters("CHAT_MSG_WHISPER_INFORM")
for i in pairs(myFilters) do
ChatFrame_RemoveMessageEventFilter("CHAT_MSG_WHISPER_INFORM", myFilters[i])
end
end
local myFilters = ChatFrame_GetMessageEventFilters("CHAT_MSG_WHISPER_INFORM")
rekkFilters()
local myFilters = ChatFrame_GetMessageEventFilters("CHAT_MSG_WHISPER_INFORM")
if myFilters[1] ~= nil then
rekkFilters()
end
I need to use MTD with Json to dinamycally create forms, but also i need to check the user input:
Some fields may only accept numbers, and some other have a fixed length etc.
This can be done with an action that checks every EntryElement value against the specified conditions, and then using some messaging to tell the user about the necessary corrections.
If we have a low number of fields this is Ok, but when one has more than 50 fields then this turn out to be very awkward in terms of usability. The ideal solution would be to notify the user about corrections, in the moment the user ends typing in the EntryElement
Now MTD provides some sort of mechanism to do this:
JsonElement jsonElement;
jsonElement = JsonObject.Load("file.json");
((EntryElement) jsonElement["field_1"]).EntryEnded = delegate { doSomething();};
Provided that "field_1" is an EntryElement marked with the id attribute with "field_1" value
The above code works as expected, ie: When i change the focus to another part, the EntryEnded event activates. Now for the million dollar question:
How do i know to which EntryElement does the Event correspond? or in other words. How do i get the ID of the EntryElement when calling the Event?
If none of the above is possible which would be suitable solution?
Thanks in advance for any leads,
Found a way to do it:
((EntryElement)jsonElement ["field_1"]).EntryEnded += (object sender, EventArgs e ) =>
{
NSIndexPath pt = ((EntryElement)sender).IndexPath;
Console.WriteLine("section: "+pt.Section+" row: "+pt.Row);
};
This little thing will print the Section and the Row of the EntryElement that received
the EntryEnded event. This is not exactly as getting the id, but at least now i have information about its location, and from this i can get a lot more info (specially if i took care to save it somewhere else)
This is probably a basic trick, but i didn`t found it anywhere else!
I have created a class that I've been using as the storage for all listings in my applications. The class allows me to "sign" an object to a listing (which can be created on the fly via the sign() method like so):
manager.sign(myObject, "someList");
This stores the index of the element (using it's unique id) in the newly created or previously created listing "someList" as well as the object in a 2D array. So for example, I might end up with this:
trace(_indexes["someList"][objectId]); // 0 - the object is the first in this list
trace(_instances["someList"]); // [object MyObject]
The class has another two methods:
find(signature:String):Array
This method returns an array via slice() containing all of the elements signed with the given signature.
findFirst(signature:String):Object
This method just returns the first object in a given listing
So to retrieve myObject I can either go:
trace(find("someList")[0]); or trace(findFirst("someList"));
Finally, there is an unsign() function which will remove an object from a given listing. This function basically:
Stores the result of pop() in the specified listing against a variable.
Uses the stored index to quickly replace the specified object with the pop()'d item.
Deletes the stored index for the specified object and updates the index for the pop()'d item.
Through all this, using unsign() will remove an object extremely quickly from a listing of any size.
Now this is all well and good, but I've had some thoughts which are making me consider how good this really is? I mean being able to easily list, remove and access lists of anything I want throughout the application like this is awesome - but is there a catch?
A couple of starting thoughts I have had are:
So far I haven't implemented support for listings that are private and only accessible via a given class.
Memory - this doesn't seem very memory efficient. Then again, neither is creating arrays for everything I want to store individually either. Just seems.. Larger.. Somehow.
Any insights?
I've uploaded the class here in case the above doesn't make much sense: https://projectavian.com/AviManager.as
Your solution seems pretty solid. If you're looking to modify it to be a bit more extensible and handle rights management, you might consider moving all those individually indexed properties to a value object for your AV elements. You could perform operations like "sign" and "unsign" internally in the VOs, or check for access rights. Your management class could monitor the collection of these VOs, pass them around, perform the method calls, and the objects would hold the state in a bit more readable format.
Really, though, this is entering into a coding style discussion. Your method works and it's not particularly inefficient. Just make sure the code is readable, encapsulated, and extensible and you're good.
Im working on a mvc 2.0 application using the entity framework. With the entityframework I use the repository pattern with poco objects. To start off with the issue, when I convert an entity object to json I get a circular reference error.
After some search I discovered that there are proxy's generated to support lazy loading. If there are navigation properties between two classes (A and B), this results in a circurar reference error. Quite understandable. So I try to work around it.
I disabled the proxies and the lazy loading. This works if I only want to load Class A. Instead of the proxy's there are now null values, so they can be parsed.
But now I want to load a class, for instance Orders and I want to see what customer placed the order:
Suppose I have class Customer that has a navigation property to Order (1 to more) and Order has a reversed navigation property to Customer. When I turn the proxys off, I get a nice json back with all the orders, but not with the Customers. When I turn the proxies on, I get a circular error.
But how could I get back the orders, with the customer that bought them. Is it possible to create a linq that retreives the orders and load the customers (I have a repository for both customers and orders)? Or is there a way to strip off the proxy-objects?
I hope my post is clear enoug and someone can help me.
Problem:
Right. So you have the relationship A -> B with B being the many side.
in the EF model A gets a navigation property B and B gets a navigation property A.
Circular reference... great...
Solution:
In your model, rightclick on the B's navigation property A and choose properties.
Getter and setter there should both be public initially. Set the getter to Private.
Now something like this should work.
var results = from a in ctx.A.Include("B")
select a;
var list = results.ToList(); //This is important otherwise youll get a error that the context has been disposed on the next line.
return Json(list, JsonRequestBehavior.AllowGet);
Hope this helps.
PS:
After reading my answer after posting it, I'm not so sure anymore that I'm really answering your question, sorry. Ill leave it up nonetheless.
How can I validate the cells in a DataGridColumn individually? (ActionScript 3.5) The validation is configured per-cell, based on fields in the given row. For example
FIELD VALUE TYPE
age 13 Integer
height 13x3 Integer
registered true Boolean
temperature 98.G6 Float
In this case, of course 13x3 and 98.G6 would be invalid.
It's easy to write a Validator ; and to access the data provider objects.
But how do I get individual access to the GUI cell objects so I can set the errorString on an individual cell, either directly or through a Validator?
The itemRenderer/ TextInput control is re-used across the cells for performance reasons, so accessing the GUI-level objects is tricky.
Edit
Answers:
One way to validate and display the invalidation markings, but not per-cell, is to validate all data-provider objects and then set the errorString on the entire grid.
One way to validate per-cell is on the itemEditEnd event handler. (See these pages A B C D). One disadvantage is that it only allows access to the cells from the "inside", not in an action that validates the grid on command.
A custom itemRenderer is another possibility, as in the answer below, but like 3 above, it only allows access to the cells from the "inside", not in an action that validates the grid on command.
See Richard Haven's answer below.
And here's how to access the GUI objects: The list of relevant GUI objects is a protected field; so you can access it by subclassing, then iterate over the GUI-components which represent the cells and set the errorString on each one.
This website at BigResource asks how to access an individual cell. The third post answers there question and provides a link to a better resource than this. Figured you would want both. Hopefully this helps.
If you are looking for arbitrary validation (e.g. on a button or page navigation) rather than immediate navigation (e.g. on cell exit or end-of-edit), then the data is in the underlying dataProvider. I would do validations there rather than dig around inside the grid.
You can add a flag to the data item so the item renderer displays it as an error (or use an external list to flag it).
Cheers
Are you sure you actually want to access the individual cells' DisplayObjects? The component manages instances so that it only creates as many as it needs to display (so that huge datasets don't require a huge number of DisplayObjects on screen).
I think a better alternative would be to provide your DataGridColumn with a custom itemRenderer. You can write this class to accept a validator and update its appearance, and there are a bunch of great tutorials around about that.