| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- <html>
- <head>
- <title>Blitz3D Docs</title>
- <link rel=stylesheet href=../css/commands.css type=text/css>
- </head>
- <body>
- <h1>RecvNetMsg()</h1>
- <h1>Parameters</h1>
- <table>
- <tr>
- <td>
- None.
- </td>
- </tr>
- </table>
- <h1>Description</h1>
- <table>
- <tr>
- <td>
- First off, this ONLY works when you have joined a network game via StartNetGame or JoinNetGame and you have created a player via CreateNetPlayer (you must create a player, even if it is just to lurk).
<br />
-
<br />
- This returns a TRUE value if a message was received, FALSE if none has been received. This will typically go inside a function that is constantly being checked for message and decode and handle them. You will use NetMsgType, NetMsgFrom, NetMsgTo, and NetMsgData$ to get the important information from the message and act on it.
<br />
-
<br />
- The example requires that you run it on a remote machine while the local computer runs the example in the SendNetMsg command.
- </td>
- </tr>
- </table>
- <h1><a href=../2d_examples/RecvNetMsg.bb>Example</a></h1>
- <table>
- <tr>
- <td>
- ; RecvNetMsg() example
<br />
- ; --------------------
<br />
- ; Run this program on the REMOTE computer to 'watch'
<br />
- ; the activity of the SendNetMsg example. Run that
<br />
- ; example on local machine.
<br />
- ;
<br />
- ; This program will tell you when a player involved in
<br />
- ; the game hits a wall ...
<br />
-
<br />
- ; We'll use this instead of JoinHostGame - make it easier
<br />
- StartNetGame()
<br />
-
<br />
- ; Create a player - a player must be created to
<br />
- ; receive mesages!
<br />
- playerID=CreateNetPlayer("Shane")
<br />
-
<br />
- ; Loop and get status
<br />
- While Not KeyHit(1)
<br />
-
<br />
- ; Check to see if we've received a message
<br />
- If RecvNetMsg() Then
<br />
-
<br />
- ; if we did, let's figure out what type it is
<br />
- ; we know it will be a user message, though
<br />
- msgType=NetMsgType()
<br />
-
<br />
- ; 1-99 means a user message
<br />
- If msgType>0 And msgType<100 Then
<br />
-
<br />
- ; Let's see who the message was from
<br />
- msgFrom=NetMsgFrom()
<br />
-
<br />
- ; Let's get the message!
<br />
- msgData$=NetMsgData$()
<br />
-
<br />
- ; Print the message
<br />
- Print msgData$
<br />
- End If
<br />
- End If
<br />
- Wend
<br />
- </td>
- </tr>
- </table>
- <br>
- <a target=_top href=../index.htm>Index</a><br>
- <br>
- Click <a href=http://www.blitzbasic.co.nz/b3ddocs/command.php?name=RecvNetMsg&ref=comments target=_blank>here</a> to view the latest version of this page online</body>
- </html>
|