|
I am recieving RTMP packet from flash.
It is for flash Object.
Now the data in object may get change runtime.
So how can i do same thing as like flash in MFC?
Is there any facility in MFC through which i can do this?
|
|
|
|
|
I still don't know what you are trying to do. So you receive a packet and it contains some data. How is this packet structured and how do you know which kind of data is contained in the packet ? What are the different data types that you can receive ?
When you need to use this data later, how will you use it ? What will you do with it and how will you identify what kind of data it is ?
You cannot just store any kind of data (well, not easily and it is in general far from being good practice), so what I'm trying to do is understand what you are trying to do in order to help. So, if you don't give enough information, I cannot help (and saying that you want to store any kind of data is not really usefull information). So, please be complete in your answer.
|
|
|
|
|
packet can contain array or object
If it is a objet then it can contain many values like int, double, char *, or another object, etc.
Thats not problem, my program can identify it at run time.
Now the problem is that how can i store these values so that i can access it again?
Is there any facility of assigning properties of object at runtime?
Any idea??
Manish Patel
B.E. - Information Technology.
|
|
|
|
|
Well, you don't give a lot of information do you ?
Manish_mnp wrote: packet can contain array or object
And how are you supposed to make the difference ? How do you know that the packet contains an object or an array ?
Manish_mnp wrote: If it is a objet then it can contain many values like int, double, char *, or another object, etc.
Same, how do you know which kind of data it is ? How is this information coded ? Qnd zhqt qre the other objects you can put in the packet ?
Manish_mnp wrote: Thats not problem, my program can identify it at run time
Yeah, but that's my problem. I cannot understand your problem until you explain it clearly. How can you identify what is contained in this damn packet ?
Manish_mnp wrote: Is there any facility of assigning properties of object at runtime?
Ok, stop focusing on that and try to explain your problem as if it was impossible to do that. Then, we can discuss a possible solution. But honnestly, I hardly see a reason to use things like VARIANT because it will probably cause a lot of troubles.
Please, post some code snippet and the description of a typical packet. Without more information it is quite difficult to help you. And what are you supposed to do with what is contained in the packet ??
|
|
|
|
|
I am doing it through VARIANT
Now i am providing you a sample code here
<br />
VARIANT var, var2;<br />
var.dblVal = 2.0;
var.vt = VT_DECIMAL;<br />
<br />
MyObject *myObj, *myObj2, *retObj;
myObj = new MyObject();<br />
myObj2 = new MyObject();<br />
myObj->setProperty(CString("DOUBLE"), var);
var2.byref = myObj;<br />
var2.vt = VT_PTR;<br />
<br />
myObj2->setProperty(CString("OBJECT"), var2);<br />
retObj = (MyObject *)myObj2->getProperty(CString("OBJECT")).byref;<br />
<br />
CString st;<br />
st.Format(CString("Val::%f"), retObj->getProperty(CString("DOUBLE")).dblVal);<br />
AfxMessageBox(st);<br />
<br />
This code run perfactly but it is required that we have to provide perticular value(as .byres, .dblVal)
Is there any alternative to this code so that i can assigen all values by using only one Type(like obj.val = value)
Any Sugession ?
Manish Patel
B.E. - Information Technology.
|
|
|
|
|
|
I want the facility such that i can store my variable of different data type like double, int, char *, My own Object.
Any idea?
Manish Patel
B.E. - Information Technology
|
|
|
|
|
Have a look to MFC support for VARIANT datatype (or create a custom union by yourself).
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
Ya i know it but how can it store my custom class refernce(object)?
Manish Patel
B.E. - Information Technology
|
|
|
|
|
Manish_mnp wrote: Ya i know it
And you know also about pointers ?
Hint: try to be more specific, or post the relevant code snippet.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
|
|
|
|
|
now data can be anything
-int
-float
-char*
-an object of your class (object will also contain data in the form of int, float, char* )
etc..
So all the data can be converted in the form of char*
like this
<br />
char data[4]<br />
int i<br />
float f<br />
memcpy(data, &i, sizeof(i));<br />
memcpy(data, &f, sizeof(f));<br />
if there is any object of a class
provide a member function which will
- take char*
- allocate memory that is used by all the data in class
- and finally convert all the data in the form of char *
just a kind of Serialization that is provided by MFC
|
|
|
|
|
Have you considered a void* to hold such data?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
I have a 3 thread MFC application. Out of these one sub thread should be used for displaying video at intervals of 40ms. How do i create a periodic timer to accomplish this job. I have seen the SetTimer function. How to manage the timer from the display thread. How to get the parameters such as HWND,TimerProc parameter etc.
|
|
|
|
|
Try the following:
//You can set the timer in one of the funtions of some class
//probably in some constructor
//m_nTimer1 will be declared as unsigned int in that class
m_nTimer1 =CWnd::SetTimer(1,40,0);//for 40 ms
//After 40 ms the following function will get called
void YourClass::OnTimer(UINT nIDEvent)
{
if(nIDEvent==1)
{
CWnd::KillTimer(m_nTimer1);
/***Call your display function here****/
m_nTimer1 =CWnd::SetTimer(1,40,0);//Then again set your timer
//for 40 ms
}
}
|
|
|
|
|
Since you have a thread to show the video, timer is not needed. You can use Sleep API in the loop. But the problem is that it cannot give you a much precision. You have to play the video on by looking at the time (I think GetTickCount is useful) instead of using sleep for a real time video show.
- NS -
|
|
|
|
|
For the display of the video should use the main MFC thread (your app). So use the normal OnTimer() handling.
For standard use I create a main MFC app, and for special use a "worker" thread for communicating with devices or greater mathematical operations.
Greetings from Germany
|
|
|
|
|
I am using CreateThread() function to create worker threads. Are there any other ways to create threads in MFC applications. Why I have this doubt is because my application is utilizing full 100% of CPU all the time. My application has one serial port reading thread which should take only very little CPU another a fully mathematical thread and third a display thread.
|
|
|
|
|
The high CPU utilization is very bad. It is in best case a missdesign in worst a bug.
Identify and eliminate this via Sleep(), a Timer or Waiting for a Event.
Greetings from Germany
|
|
|
|
|
jossion wrote: I am using CreateThread() function to create worker threads. Are there any other ways to create threads in MFC applications.
With MFC, you should be using AfxBeginThread() .
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
jossion wrote: Out of these one sub thread should be used for displaying video at intervals of 40ms. How do i create a periodic timer to accomplish this job.
You probably shouldn't, since the primary thread owns the UI. Instead, have the secondary thread post a message to the primary thread indicating what needs to be displayed.
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi friends,
I have developed a software involving sockets-parsing-database transfer. I can connect upto 6 machines to this software(s/w). These machines send out data on TCP/IP. Thus on s/w's end i have six OnReceive() events(Please note that so far there is no mention of threads)
There are 2 types of string that these machines can send to the s/w: transaction string and the other one is batch-string. Upon receiveing a batch-string the s/w assigns a batch number to all previous transaction strings and then transfers these strings to MS SQL database(DB). E.g. i take 5 transactions then generate a batch-string thus the DB will contain 5 rows with batch no. provided by the batch string i.e. batch string is used only to assign a 'batch no.'. While the transactions are being taken the data is stored in a CString array.
Apart from this the s/w sends an 'OK' display message to the machine if a string is received. This OK message is cleared only at the end of 'parsing function'(OnReceive->Parsing->Store in variables->Send OK->Transfer to DB if batch-string->Wait for 3 secs and Clear OK[seperate thread]).
Now the question is there are cases where in a valid string is getting missed/not captured by the s/w. Note that valid strings are transmitted out only once and there is no handshake. Also there are cases where in an OK message is displayed but still some row goes missing in the DB.
What are problem areas in this? How can i make this s/w more efficient??
P.S: Kindly let me know if more data is needed
|
|
|
|
|
I'd say this is too much information.
It's hard to tell how to help.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
Am doing a little code review...
Is it safe to delete a CWnd derived object immediately following a call to CWnd::DestroyWindow on it?
I would assume yet -- but if not, when is it safe to do so?
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~<br />
Peter Weyzen<br />
Staff Engineer<br />
<A HREF="http://www.soonr.com">SoonR Inc -- PC Power delivered to your phone</A>
|
|
|
|
|
See CWnd::PostNcDestroy()
- NS -
|
|
|
|
|