[ Nettention - ProudNet ]
공유된 파일 다운로드
공유 컴퓨터 접속
실행 >> \\YCS-PC
id : ycs ps : 1234
StudyOnly 폴더 내의 파일 카피
프라우드넷 라이브러리 설치
ProudNet \ Library설치파일 : ProudNet_______ 파일을 받아서 설치
설치 과정에 Key 값을 요구하면 아래 키 값을 복사해서 넣으면 됨
프라우드넷 모바일 라이센스키
JJLPX7NU-UD2R34AG-XKZKG2P4-HCT6YH2Y-BYHABOA5-YI5Q25YV-5365Z25Z-LFZYFZRG-ZUKZVZJU-CFU6NUQ7-UUCABWKK-EKK4EKQC-KUYQAGNK-FRKMHKA6-KEW2FVKE-HWE6WEWV-EUTUXVUW-FYW5OWRD-WXLGUROV-7OVOAVOZ-VMVFPQ5O-AFORLOSJ-OTQORR6R-AWRRERRD-RTARQFJR-JFRPXRHI-RHPRGNBH-6ZHNLHJG-HPIXMSXN-73NO7NOT-NM2NP5VO-2VOSNO6R-OZ6DQU5D-GAWQEFBJ-N5A7DRQU-LVOVMH44-IWIUT7J3-MRZ33GYC-CUAIBFCS-67JHBLNQ-5QSUQU6Y-OYPAR5CR-A7TQKLLK
실행파일 : Unity\SngClient\SngClient.exe
Server adress: 115.88.210.158
Ville Name : Janna
서버 컴퓨터 : 115.88.210.158
동영상 강의 : http://www.screencast.com/t/3scpMaVgb
## 소스코드
using UnityEngine;
using System;
using System.Collections;
using Nettention.Proud;
public class GameClient : MonoBehaviour {
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
m_netClient.FrameMove();
}
void OnDestroy()
{
m_netClient.Dispose();
}
NetClient m_netClient = new NetClient();
string m_failMessage = "";
//SocialC2S.Proxy m_C2SProxy = new SocialC2S.Proxy();
//SocialS2C.Stub m_S2CStub = new SocialS2C.Stub();
string m_serverAddr = "localhost";
string m_villeName = "Janna";
bool m_requestNewVille = false;
string m_loginButtonText = "Connect!";
enum State { Standby, Connecting, LoggingOn, Inville, Failed}
State m_state = State.Standby;
void OnGUI()
{
GUI.Label(new Rect(10, 10, 300, 70), "ProudNet example : \na simple social ville");
GUI.Label(new Rect(10, 60, 180, 30), "Server address");
m_serverAddr = GUI.TextField(new Rect(10, 80, 180, 30), m_serverAddr);
GUI.Label(new Rect(10, 110, 180, 30), "Ville name");
m_villeName = GUI.TextField(new Rect(10, 130, 180, 30), m_villeName);
m_requestNewVille = GUI.Toggle(new Rect(10, 160, 180, 20), m_requestNewVille, "Create a new ville");
if (GUI.Button(new Rect(10, 190, 100, 30), m_loginButtonText))
{
if (m_state == State.Standby)
{
m_state = State.Connecting;
m_loginButtonText = "Connecting...";
IssueConnect();
}
}
}
void IssueConnect()
{
NetConnectionParam cp = new NetConnectionParam();
cp.serverIP = m_serverAddr;
cp.serverPort = 12349;
cp.protocolVersion = new Guid("{0xa90a5fc4,0x2b62,0x46f8,{0xbb,0xc4,0xf6,0xea,0xc1,0xef,0x70,0x26}}");
m_netClient.Connect(cp);
}
}
using UnityEngine;
using System;
using System.Collections;
using Nettention.Proud;
public class GameClient : MonoBehaviour {
// Use this for initialization
void Start () {
m_netClient.AttachProxy(m_C2SProxy);
m_netClient.AttachStub(m_S2CStub);
m_S2CStub.ReplyLogon = (Nettention.Proud.HostID remote, Nettention.Proud.RmiContext rmiContext, int result, String comment) =>
{
if (result == 0)
{
m_state = State.Inville;
Debug.Log("Connect!!");
}
else
{
m_state = State.Failed;
m_failMessage = "Logon failed : " + result.ToString() + " " + comment;
}
return true;
};
}
// Update is called once per frame
void Update () {
m_netClient.FrameMove();
}
void OnDestroy()
{
m_netClient.Dispose();
}
NetClient m_netClient = new NetClient();
string m_failMessage = "";
SocialC2S.Proxy m_C2SProxy = new SocialC2S.Proxy();
SocialS2C.Stub m_S2CStub = new SocialS2C.Stub();
string m_serverAddr = "localhost";
string m_villeName = "Janna";
bool m_requestNewVille = false;
string m_loginButtonText = "Connect!";
enum State { Standby, Connecting, LoggingOn, Inville, Failed}
State m_state = State.Standby;
void OnGUI()
{
switch (m_state)
{
case State.Standby:
case State.Connecting:
case State.LoggingOn:
OnGUI_Logon();
break;
case State.Inville:
OnGUI_Inville();
break;
case State.Failed:
GUI.Label(new Rect(10, 30, 200, 80), m_failMessage);
if (GUI.Button(new Rect(10, 100, 180, 30), "Quit"))
{
Application.Quit();
}
break;
}
}
private void OnGUI_Inville()
{
}
private void OnGUI_Logon()
{
GUI.Label(new Rect(10, 10, 300, 70), "ProudNet example : \na simple social ville");
GUI.Label(new Rect(10, 60, 180, 30), "Server address");
m_serverAddr = GUI.TextField(new Rect(10, 80, 180, 30), m_serverAddr);
GUI.Label(new Rect(10, 110, 180, 30), "Ville name");
m_villeName = GUI.TextField(new Rect(10, 130, 180, 30), m_villeName);
m_requestNewVille = GUI.Toggle(new Rect(10, 160, 180, 20), m_requestNewVille, "Create a new ville");
if (GUI.Button(new Rect(10, 190, 100, 30), m_loginButtonText))
{
if (m_state == State.Standby)
{
m_state = State.Connecting;
m_loginButtonText = "Connecting...";
IssueConnect();
}
}
}
void IssueConnect()
{
m_netClient.JoinServerCompleteHandler = (ErrorInfo info, ByteArray replyFromServer) =>
{
if(info.errorType == ErrorType.Ok)
{
m_state = State.LoggingOn;
//m_loginButtonText = "Loggin on...";
m_loginButtonText = "Loggin on...";
m_C2SProxy.RequestLogon(HostID.Server, RmiContext.SecureReliableSend, m_villeName, m_requestNewVille);
//m_C2SProxy.RequestLogon(HostID.Server, RmiContext.SecureReliableSend, m_villeName, m_requestNewVille);
}
else
{
//m_loginButtonText = "Failed!";
m_state = State.Failed;
m_failMessage = info.ToString();
}
};
m_netClient.LeaveServerHandler = (ErrorInfo info)=>
{
m_state = State.Failed;
m_failMessage = "Server connection lost!";
};
NetConnectionParam cp = new NetConnectionParam();
cp.serverIP = m_serverAddr;
cp.serverPort = 12349;
cp.protocolVersion = new Guid("{0xa90a5fc4,0x2b62,0x46f8,{0xbb,0xc4,0xf6,0xea,0xc1,0xef,0x70,0x26}}");
m_netClient.Connect(cp);
}
}