Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by SteenPetersen · Aug 08, 2017 at 03:44 PM · networkingwebgludp

UNet, any way to identify if the incomming connection is a Browser (ie websocket) or standalone (ie UDP connection)?

As title states I have setup a server client Unet system that works both as standalone and webGL. However when in the editor the client always send its connection as a standalone and then testing in the browser it always sending as websocket. Id like to have the server do different things depending on the type of connection so I can speak to both.

Just wondering what the easiest way to do this is?

thanks.

Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by BlackHack_ · Aug 15, 2017 at 04:24 PM

The easiest way is to use messages, when the player connects make him send to the server which type of connection he is using, and on the server store that in a dictionary storing the connection and the type.

 class MyMsgType
 {
     public const short SendConnectionDataMsg = MsgType.Highest + 1;
 }
 
 class Client : NetworkBehaviour
 {
     void Start()
     {
         NetworkManager.singleton.client.RegisterHandler(MsgType.Connect, netMsg =>
         {
             NetworkManager.singleton.client.Send(MyMsgType.SendConnectionDataMsg, new ConnectionDataNetMsg()
             {
                 isWebPlayer = Application.isWebPlayer
             });
         });
     }
 }
 
 class Server : NetworkBehaviour
 {
     Dictionary<NetworkConnection, bool> connectionTypes = new Dictionary<NetworkConnection, bool>();
 
     void Start()
     {
         NetworkServer.RegisterHandler(MyMsgType.SendConnectionDataMsg, netMsg =>
         {
             var msg = netMsg.ReadMessage<ConnectionDataNetMsg>();
             connectionTypes[netMsg.conn] = msg.isWebPlayer;
         });
     }
 }
 
 class ConnectionDataNetMsg : MessageBase
 {
     public bool isWebPlayer;
 }

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image SteenPetersen · Aug 15, 2017 at 04:40 PM 0
Share

Thanks for the answer but I see from your script that it's using the HLAPI and I'm using the LLAPI so I don't use network behavior or network manager. However I think Since the standalone version is a client I'll simply make the client send a message saying they are a standalone client and therefore default will be browser. That should fix it.

Thanks for your time tho appreciate it but not exactly what I need sadly :( no way to assess if it's correct or not.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

99 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

UDP Sockets for networking, getting overloaded?? 0 Answers

Local host in WebGL 1 Answer

Does Unity Support TCP or only UDP? 0 Answers

UdpClient EndRecieve recieves a list of null bytes 0 Answers

Receive value from UDP connection 0 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges