Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 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 Matt 6 · Oct 28, 2010 at 01:42 PM · messaging

Creating and using a WebServiceHost

So I'm working on getting a communication channel open between my Unity game and a menu service written in WPF and C#. I've been having issues getting services to launch and finally came across the WebServiceHost. I was able to implement it in unity, it seems to open and return to me a CommunicationState.Opened state so it seems to have opened and be running but when I try to send a message to it through my web browser it tells me Bad Request (Invalid host). I'm very new to trying to do this so if my explanation is wrong I apologize. Below is the code I'm using to create and start the service as well as the messaging class. Also I'm entering http://localhost:9098/AMI/Megatouch/ShowInGameMenu?name=Quit into my web browser

[ServiceContract] public interface IInGameMenuMessaging { [OperationContract] [WebGet(UriTemplate = "ShowInGameMenu?name={name}")] void ShowInGameMenu(string name);

 [OperationContract]
 [WebGet(UriTemplate = "HideInGameMenu")]
 void HideInGameMenu();

}

[ServiceBehavior(InstanceContextMode = InstanceContextMode.Single)] public class InGameMessaging : IInGameMenuMessaging {

 public void ShowInGameMenu(string name)
 {
     //Console.WriteLine("Inside ShowInGameMenu:{0}", name);
     Debug.Log("Inside ShowInGameMenu:");
 }

 public void HideInGameMenu()
 {
     Console.WriteLine("Inside HideInGame");
 }

}

public class service_host { public WebServiceHost StartHost() { Debug.Log("The service is Starting."); var game_object = new InGameMessaging(); var host = new WebServiceHost(game_object, new Uri("http://localhost:9098/AMI/Megatouch")); var ep = host.AddServiceEndpoint(typeof(IInGameMenuMessaging), new WebHttpBinding(), "InGameMenu"); host.Open(); return host;

 }

}

WebServiceHost _webhost;

public static service_host host = new service_host(); // Use this for initialization void Start() { _webhost = host.StartHost(); Debug.Log("Host is started"); Debug.Log("_webhost.State is " + _webhost.State.ToString());

}

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 dmitche3 · Apr 09, 2014 at 12:03 PM

Have you had any success with this? I'm banging my head against the wall with Unity3d/mono and communicating as named pipes don't work. I'm doing something similar.

Mono is still a disease that should be avoided.

Comment
Add comment · 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

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

1 Person is following this question.

avatar image

Related Questions

Multithreading and messaging 5 Answers

NetworkMessages in UNET 0 Answers

MessagingSystem.ProcessIncomingMessageQueue();, NullReferenceException: Object reference not set to an instance of an object 1 Answer

Wiring Script & Relaying Messages 0 Answers

Using MessageQueue.Send() 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