Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*-----------------------------+------------------------------\
- | |
- | !!!NOTICE!!! |
- | |
- | These libraries are under heavy development so they are |
- | subject to make many changes as development continues. |
- | For this reason, the libraries may not be well commented. |
- | THANK YOU for supporting forge with all your feedback |
- | suggestions, bug reports and comments! |
- | |
- | - The Forge Team |
- | Bearded Man Studios, Inc. |
- | |
- | This source code, project files, and associated files are |
- | copyrighted by Bearded Man Studios, Inc. (2012-2015) and |
- | may not be redistributed without written permission. |
- | |
- \------------------------------+-----------------------------*/
- using UnityEngine;
- using BeardedManStudios.Network;
- public class ForgeExample_WriteCustom : MonoBehaviour
- {
- public const uint CUSTOM_ID = 55000;
- private void Start()
- {
- Debug.Log("Registering read callback event");
- Networking.PrimarySocket.AddCustomDataReadEvent(CUSTOM_ID, onRead);
- }
- private void Update()
- {
- if (Input.GetKeyDown(KeyCode.Space))
- {
- string username = "Dennis";
- string password = "Password";
- ulong data = 9uL;
- ushort LoginReq = 2;
- BMSByte dataCache = new BMSByte();
- dataCache.Clone(ObjectMapper.MapBytes(dataCache, LoginReq, username, password, data));
- Networking.WriteCustom(CUSTOM_ID, Networking.PrimarySocket, dataCache, true, NetworkReceivers.All);
- }
- }
- public void onRead(NetworkingPlayer sender, NetworkingStream stream)
- {
- ushort LoginReq = ObjectMapper.Map<ushort>(stream);
- string uname = ObjectMapper.Map<string>(stream);
- string password = ObjectMapper.Map<string>(stream);
- ulong ID = ObjectMapper.Map<ulong>(stream);
- Debug.Log(LoginReq);
- Debug.Log(uname);
- Debug.Log(password);
- Debug.Log(ID);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement