Click here to Skip to main content
15,867,330 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Interprocess communication in C without pipes or disk Pin
Espen Harlinn12-Jul-17 14:03
professionalEspen Harlinn12-Jul-17 14:03 
GeneralRe: Interprocess communication in C without pipes or disk Pin
leon de boer12-Jul-17 18:49
leon de boer12-Jul-17 18:49 
AnswerRe: Interprocess communication in C without pipes or disk Pin
Randor 13-Jul-17 14:08
professional Randor 13-Jul-17 14:08 
GeneralRe: Interprocess communication in C without pipes or disk Pin
Chris Maunder19-Jul-17 6:01
cofounderChris Maunder19-Jul-17 6:01 
AnswerRe: Interprocess communication in C without pipes or disk Pin
Joe Woodbury17-Jul-17 10:53
professionalJoe Woodbury17-Jul-17 10:53 
Questionwhich one would be better? Pin
bestbear11-Jul-17 1:51
bestbear11-Jul-17 1:51 
AnswerRe: which one would be better? Pin
Jochen Arndt11-Jul-17 3:41
professionalJochen Arndt11-Jul-17 3:41 
AnswerRe: which one would be better? Pin
leon de boer11-Jul-17 5:50
leon de boer11-Jul-17 5:50 
It is actually the situation where you use a delegate.

It is very common on game servers which are doing things like guns/projectiles etc to do this. The reason is you want to bind a behaviour to a random class without worrying what the class is and going thru the issue you have. So when I have a bullet I don't care if it's a 50 cal, 45 magnum or a BB pellet it has a behaviour and I will execute the delegate function to move it and use the payload to hold a callback for the object to draw itself and vary the damage etc. The classes don't even have to be related to use a delegate they can have random relationships and it's safe.

So unlike a class/object a delegate is an action or an event and generally it carries a payload which can be other actions or objects. You called your function DoSomething and it goes to another object Smile | :)

The other cute thing is you can add and delete delegates at any time to an object and you can test for the presence of a delegate. So you can add/delete and turn on/off functionality to a class/object with ease without the class itself needing to know or building that functionality on all related classes.

All real game engines do it that way and typically your server connects to players etc via delegates. Usually it is just doing things like scoring etc and removing dead people etc so it doesn't care what the objects are it just needs a couple of things from them. The last thing you want the server doing is get involved heavily in the objects or you will bottleneck everything. When an object disconnects from the server it simply removes itself from the server multicast delegates and the server will no longer see it and it's free to delete itself or whatever in it's own good time. So typically a server doesn't get involved in creating or deleting objects either which is the responsibility of a spawn system(s).
Delegates | Unreal Engine[^]
Unity - Delegates[^](worth watching the video to see it's use in a game)

Unreal Engine has the classical layout (look at the block diagram at bottom) .. GameServer sits alone things only join
Gameplay Framework Quick Reference | Unreal Engine[^]

There are a number of articles on C/C++ delegates on this site and good old google will throw hundreds and obviously MS has a sample as Visual Studio has them.
delegate (C++ Component Extensions)[^]

You might also want to look at C++ Events which we sometimes use in place of a delegate Smile | :)
In vino veritas


modified 11-Jul-17 23:04pm.

AnswerRe: which one would be better? Pin
bestbear11-Jul-17 17:18
bestbear11-Jul-17 17:18 
Questionwhich one would be better? Pin
bestbear11-Jul-17 1:18
bestbear11-Jul-17 1:18 
Questionquestions plz solve throught c or c++ Pin
Member 1330375110-Jul-17 22:51
Member 1330375110-Jul-17 22:51 
AnswerRe: questions plz solve throught c or c++ Pin
CodeWraith10-Jul-17 23:21
CodeWraith10-Jul-17 23:21 
AnswerRe: questions plz solve throught c or c++ Pin
Richard MacCutchan11-Jul-17 0:21
mveRichard MacCutchan11-Jul-17 0:21 
AnswerRe: questions plz solve throught c or c++ Pin
Patrice T16-Jul-17 17:34
mvePatrice T16-Jul-17 17:34 
QuestionHow to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici10-Jul-17 8:07
lolici10-Jul-17 8:07 
AnswerRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Richard MacCutchan10-Jul-17 21:28
mveRichard MacCutchan10-Jul-17 21:28 
AnswerRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt10-Jul-17 21:38
professionalJochen Arndt10-Jul-17 21:38 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici11-Jul-17 8:33
lolici11-Jul-17 8:33 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt11-Jul-17 9:08
professionalJochen Arndt11-Jul-17 9:08 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici11-Jul-17 9:18
lolici11-Jul-17 9:18 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
lolici15-Jul-17 3:53
lolici15-Jul-17 3:53 
GeneralRe: How to save the filename retrieved from a dialog class using CMFCEditBrowseCtrl? Pin
Jochen Arndt15-Jul-17 22:00
professionalJochen Arndt15-Jul-17 22:00 
QuestionProblem in precedence of operators. Pin
parkavikkk7-Jul-17 21:25
parkavikkk7-Jul-17 21:25 
AnswerRe: Problem in precedence of operators. Pin
Richard MacCutchan7-Jul-17 22:02
mveRichard MacCutchan7-Jul-17 22:02 
GeneralRe: Problem in precedence of operators. Pin
parkavikkk7-Jul-17 22:30
parkavikkk7-Jul-17 22:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.