|
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.ServiceModel;
using System.ServiceModel.Description;
using System.Runtime.Serialization;
using System.ServiceModel.Channels;
using MADMeeting.ServiceLibrary;
namespace MADMeeting.MMServer
{
public partial class MMServer : Form
{
//Constructor
public MMServer(int PortNumber)
{
InitializeComponent();
CMMServiceHost MSHost = new CMMServiceHost();
MSHost.StartServer(PortNumber);
}
}
public class CMMServiceHost
{
System.ServiceModel.ServiceHost MMServiceHost;
public CMMServiceHost()
{
MMServiceHost = new System.ServiceModel.ServiceHost(typeof(MMService));
}
public void StartServer(int PortNumber)
{
try
{
String HTTPUri = @"http://localhost:" + PortNumber.ToString() + "/MMeeting/";
String TCPUri = @"net.tcp://localhost:" + (PortNumber + 2).ToString() + "/MMeeting/";
NetTcpBinding TcpBinding = new NetTcpBinding();
WSDualHttpBinding HttpBinding = new WSDualHttpBinding();
ServiceMetadataBehavior Metadata = new ServiceMetadataBehavior();
Metadata.HttpGetEnabled = true;
Metadata.HttpGetUrl = new Uri(HTTPUri);
TcpBinding.Security.Mode = SecurityMode.None;
MMServiceHost.AddServiceEndpoint("MADMeeting.ServiceLibrary.IMMService", HttpBinding, HTTPUri);
MMServiceHost.AddServiceEndpoint("MADMeeting.ServiceLibrary.IMMService", TcpBinding, TCPUri);
MMServiceHost.Description.Behaviors.Add(Metadata);
MMServiceHost.Open();
}
catch (Exception ex)
{
MessageBox.Show("Error in Starting the Application -" + ex.Message);
}
}
public void StopServer()
{
if (MMServiceHost.State != CommunicationState.Closed)
MMServiceHost.Close();
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
Working in KLA-Tencor, Chennai as Technical Lead. Born in Bapatla, Guntur (dt), Andhra Pradesh. B.Tech from Bapatla Engineering College, M.Tech from IIT Kanpur.
Interesting areas include Image Processing, C# .NET.