本文整理汇总了C#中Service.Connect方法的典型用法代码示例。如果您正苦于以下问题:C# Service.Connect方法的具体用法?C# Service.Connect怎么用?C# Service.Connect使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Service
的用法示例。
在下文中一共展示了Service.Connect方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: _ConnectTest
private void _ConnectTest()
{
Console.WriteLine("Connect test:");
using (Service svc = new Service("ConnectTest"))
{
svc.Start();
IPEndPoint endPoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);
// Listen
int listenSessionId = svc.Listen(endPoint);
Console.WriteLine("Listened on {0}, sessionId: {1}", endPoint, listenSessionId);
// Synchronous connect.
int connSessionId = svc.Connect(endPoint);
Console.WriteLine("Connected to {0}, sessionId: {1}", endPoint, connSessionId);
// Asynchronous connect.
svc.AsyncConn(endPoint);
// Error endpoint's asynchronous connect.
svc.AsyncConn(new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7789));
Console.WriteLine("Press any key to exit connect test...");
Console.ReadKey();
}
}
示例2: _SendRecvTest
private void _SendRecvTest()
{
Console.WriteLine("Send/Recv test:");
using (Service svc = new Service("SendRecvTest"))
{
svc.Start();
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);
int listenSessionId = svc.Listen(ep);
Console.WriteLine("Listened on [{0}], sessionId: {1}", ep, listenSessionId);
int connSessionId = svc.Connect(ep);
Console.WriteLine("Connected to {0}, sessionId: {1}", ep, connSessionId);
// Test Send
TestPacket data = new TestPacket();
data.intVal = 10086;
data.strVal = "Hello World";
svc.Send(connSessionId, data);
// Test Multicast
TestMulticastPacket multicastData = new TestMulticastPacket();
multicastData.intVal = 10010;
multicastData.strVal = "Multicast data";
List<int> multicastSessionIds = new List<int>();
multicastSessionIds.Add(connSessionId);
svc.Multicast(multicastSessionIds, multicastData);
// Test Broadcast
TestBroadcastPacket broadcastData = new TestBroadcastPacket();
broadcastData.intVal = 8888;
broadcastData.strVal = "Broadcast data";
svc.Broadcast(broadcastData);
// Test unhandled packet
svc.Send(connSessionId, new UnHandledPacket());
// Test coder not found
MemoryStream unhandledStream = new MemoryStream();
unhandledStream.Write(new byte[30], 0, 30);
svc.Send(connSessionId, 10086, unhandledStream);
Console.WriteLine("Press any key to exit Send/Recv test...");
Console.ReadKey();
}
}
示例3: CiraTecnicalTest
private void CiraTecnicalTest()
{
var tcpTransport = new TcpTransport("epp.test.cira.ca", 700, new X509Certificate("cert.pfx", "password"), true);
var service = new Service(tcpTransport);
//1. SSL connection establishment
Console.WriteLine("TEST: 1");
service.Connect();
//2. EPP <login> command with your ‘a’ account
Console.WriteLine("TEST: 2");
var logingCmd = new Login("username", "password");
var response = service.Execute(logingCmd);
PrintResponse(response);
//3. Using the correct EPP call, get the latest CIRA Registrant Agreement
Console.WriteLine("TEST: 3");
var agreementCmd = new GetAgreement();
var getAgreementResponse = service.Execute(agreementCmd);
var agreementVersion = getAgreementResponse.AgreementVersion;
var agreementText = getAgreementResponse.Agreement;
var agreementLanguage = getAgreementResponse.Language;
PrintResponse(response);
Console.WriteLine("Agreement Version:{0}", agreementVersion);
/*
4. Create a Registrant contact using:
-the same ID as your Registrar Number prefixed with the word ‘rant’ (e.g. rant75)
-CPR category CCT
-Full postal information, phone number, fax number, and email address
-Agreed to latest CIRA Registrant Agreement version
*/
Console.WriteLine("TEST: 4");
var registrantContact = new Contact("rant" + registrarNumber,
"Registrant Step Four", "Example Inc.",
"Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
"[email protected]",
new Telephone { Value = "+1.6478913606", Extension = "333" },
new Telephone { Value = "+1.6478913607" });
var registrantContactCmd = new CiraContactCreate(registrantContact);
registrantContactCmd.CprCategory = CiraCprCategories.CCT;
registrantContactCmd.AgreementVersion = agreementVersion;
registrantContactCmd.AggreementValue = "Y";
registrantContactCmd.Language = "en";
registrantContactCmd.OriginatingIpAddress = "127.0.0.1";
registrantContactCmd.CreatedByResellerId = registrarNumber;
var response1 = service.Execute(registrantContactCmd);
PrintResponse(response1);
/*
5. Create an administrative contact
-the same ID as your Registrar Number prefixed with the word ‘admin’ (e.g. admin75)
-using all mandatory elements required for a Canadian administrative contact
-omit CPR category (he have not agreed to the CIRA agreement)
*/
Console.WriteLine("TEST: 5");
var adminContact = new Contact("admin" + registrarNumber,
"Administrative Step Five", "Example Inc.",
"Toronto", "301 La Fanfan Ave.", "ON", "M5V 3T1", "CA",
"[email protected]",
new Telephone { Value = "+1.6478913606", Extension = "333" },
new Telephone { Value = "+1.6478913607" });
var adminContactCmd = new CiraContactCreate(adminContact);
adminContactCmd.CprCategory = null;
adminContactCmd.AgreementVersion = null;
adminContactCmd.AggreementValue = null;
adminContactCmd.Language = "en";
adminContactCmd.OriginatingIpAddress = "127.0.0.1";
adminContactCmd.CreatedByResellerId = registrarNumber;
const string adminContactId = "admin" + registrarNumber;
var loginresponse = service.Execute(adminContactCmd);
PrintResponse(loginresponse);
//6. Get information for the contact created in operation #4
Console.WriteLine("TEST: 6");
var getContactInfo = new ContactInfo(registrantContact.Id);
var contactInfoResponse = service.Execute(getContactInfo);
PrintResponse(contactInfoResponse);
//7. Do a Registrant transfer for domain <registrar number>-3.ca to the Registrant created in operation #4
Console.WriteLine("TEST: 7");
//NOTE: registrant transfers are domain updates
//.........这里部分代码省略.........
示例4: _PreHandleTest
private void _PreHandleTest()
{
Console.WriteLine("PreHandle test:");
using (Service svc = new Service("PreHandleTest"))
{
svc.Start();
IPEndPoint ep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7788);
Console.WriteLine("Listened on {0}", ep);
int connSessionId = svc.Connect(ep);
Console.WriteLine("Connected to {0}, sessionId: {1}", ep, connSessionId);
TestPacket data = new TestPacket();
data.intVal = 10086;
data.strVal = "Hello World";
svc.Send(connSessionId, data);
Console.WriteLine("Press any key to exit PreHandle test...");
Console.ReadKey();
}
}
示例5: ConnectPVIService
public void ConnectPVIService()
{
Log.LogInfo("Connecting PVI Service");
m_Service = new Service("Service");
m_Service.Connected += new PviEventHandler(m_Service_Connected);
m_Service.Disconnected += new PviEventHandler(m_Service_Disconnected);
m_Service.Error += new PviEventHandler(m_Service_Error);
m_Service.Connect();
}