Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

impossible to tell if you have received a new message #6

Closed
AaronMeyers opened this issue Sep 18, 2014 · 12 comments
Closed

impossible to tell if you have received a new message #6

AaronMeyers opened this issue Sep 18, 2014 · 12 comments

Comments

@AaronMeyers
Copy link

I'm not sure I understand the design of this library. Every other OSC lib I've used gets rid of old messages as you read them out. Even when I clear a ServerLog.log, the messages somehow come back.

I can't check to see if a OSCPacket is new because the TimeStamp on them is always 0.

@jorgegarcia
Copy link
Owner

Hi, I'm afraid I don't quite understand your issue yet... can you please mention more details about your problem?

Any project or code you can share so the problem can be reproduced?

Thanks,
Jorge

@heinzehavinga
Copy link

I seem to have the same problem, even when I shut down my server (I'm sending from Processing) Unity keep telling me the same message over and over. Actually on closer inspection it seems that Unity only gets the first message and ignores any other message that's coming in.

For the code I am using the test code placed on an empty object in de gameworld.

If there is anything to show this behaviour I would be glad to provide anything.

@jorgegarcia
Copy link
Owner

It would help if you share a project reproducing the problem please. In any case, you may also want to check whether the timestamp in each of the packets change (so you know that you have received a new packet). Also, have a look into the test here if you haven't done it already:

https://github.com/jorgegarcia/UnityOSC/blob/master/tests/oscControl.cs

@yourule
Copy link

yourule commented Oct 20, 2014

Hi, I encountered the same problem. Data is received by unity but only the first value is used in update. I've created a project for reproduction which you can download here:

http://www.yourule.nl/unityOSC/IncommingOSCtest.zip

Noteworthy:
In your oscControl.cs class the count of the items (item.Value.log.Count) never gets bigger than 1.

Maybe it's got something to do with this warning which pops up after pressing stop. (but not always):
Assets/OSCBundle.cs(89,41): warning CS0108: UnityOSC.OSCBundle.Unpack(byte[], ref int, int)' hides inherited memberUnityOSC.OSCPacket.Unpack(byte[], ref int, int)'. Use the new keyword if hiding was intended

I'm running Unity 4.5.5 (but also tried 4.3.0) on MacOSX 10.9.5
Same problem on Unity 4.5.3 on Windows 8.1

I also made a very small sending app for testing on Mac and PC using MaxMSP for debugging purposes
http://www.yourule.nl/unityOSC/toUnityOSC-apps.zip

BTW, i've been using the sending part for a while now, and I must say I'm impressed by your work!

@sunekastbjerg
Copy link

I encounter the same problem on Unity 4.6 Beta 20. Sending to OF works fine, but it does not update. It only updates when i start and stop the unity editor.

@yourule
Copy link

yourule commented Oct 21, 2014

Update:
If I Debug.Log(_servers[pair.Key].server.LastReceivedPacket.Data[0]); in public void UpdateLogs() I can see the values updating. The problem seems to be the timestamp always being 0, so the data is there but the writing in the dictionary fails due to the missing time stamp?

@yourule
Copy link

yourule commented Oct 21, 2014

Hack to make UpdateLogs() in OSCHandler.cs work:

public void UpdateLogs()
{
foreach(KeyValuePair<string,ServerLog> pair in _servers)
{

        if(_servers[pair.Key].server.LastReceivedPacket != null)
        {
            //Initialization for the first packet received
            if(_servers[pair.Key].log.Count == 0)
            {   
                _servers[pair.Key].packets.Add(_servers[pair.Key].server.LastReceivedPacket);

                _servers[pair.Key].log.Add(String.Concat(DateTime.UtcNow.ToString(), ".",
                                                         FormatMilliseconds(DateTime.Now.Millisecond)," : ",
                                                         _servers[pair.Key].server.LastReceivedPacket.Address," ",
                                                         DataToString(_servers[pair.Key].server.LastReceivedPacket.Data)));
                break;
            }

            //if(_servers[pair.Key].server.LastReceivedPacket.TimeStamp
            //   != _servers[pair.Key].packets[_servers[pair.Key].packets.Count - 1].TimeStamp)
            //{ 



                if(_servers[pair.Key].log.Count > _loglength - 1)
                {
                    _servers[pair.Key].log.RemoveAt(0);
                    _servers[pair.Key].packets.RemoveAt(0);
                }

                _servers[pair.Key].packets.Add(_servers[pair.Key].server.LastReceivedPacket);

                _servers[pair.Key].log.Add(String.Concat(DateTime.UtcNow.ToString(), ".",
                                                         FormatMilliseconds(DateTime.Now.Millisecond)," : ",
                                                         _servers[pair.Key].server.LastReceivedPacket.Address," ",
                                                         DataToString(_servers[pair.Key].server.LastReceivedPacket.Data)));
            //}
        }
    }
}

@jorgegarcia
Copy link
Owner

Apologies for the delay on this reply.

@yourule Thanks for pointing out a fix. If you think it's appropriate (and you well-tested it) please fork and do a pull request. Then I can review/merge the changes and other users of UnityOSC can benefit from them.

@yourule
Copy link

yourule commented Oct 21, 2014

Thank you for your reply.
For now it's a quick fix. This method resolves another problem where different messages which arrive on the same time where not passed through. I'll do some thoroughly testing and will keep you updated!

@Gamgie
Copy link

Gamgie commented Feb 3, 2015

Hi everyone !

I got the same problem. The fix of yourule works.

I did it another way (but I'm not sure this is better :p)
Just add a variable in OSCServer that is incremented each time the server receives a message. I store this as a timestamp in the OSCPacket. It ensures you have a growing timestamp for each message on each server.

In my unity app, I check an internal timestamp compared with the UnityOsc packet timestamp.

The limitation I see is that you have to store a timestamp reference for each of your OSCServer. Which is annoying.

Hope this will be fixed in the best manner found :)

@re-sounding
Copy link

I can confirm this issue both on Unity 4.6 and Unity 5 ( I've used it without any issues in older versions ). Timestamps for all packets are "0".

@jorgegarcia I've skimmed through the code and couldn't really pick out how timestamps are handled. Any insight would be very helpful.

@jorgegarcia
Copy link
Owner

Hi @ntkeep and the rest,

Apologies for the slow response!

I've just commited the change 3dba77c for generating a timestamp using the machine time when it's zero. This would happen when receiving OSC packets from applications that don't send timestamps, or if the data is not deserialised properly.

I've been doing a bit of testing today and all seems OK. Please pull and check whether this fixes the issues mentioned above. As always, feel free to create a new issue if you have further problems with UnityOSC :)

Thanks,
Jorge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants