'OLD POSTS'에 해당되는 글 56건

  1. 2012.11.28 2012년 11월 UDK 릴리즈 노트 중에서.
  2. 2012.11.27 Setting Up Configuration Files for a New Game Project
  3. 2012.04.26 PHP에서 json post 를 처리하는 방법.
  4. 2012.04.26 [C#] HttpWebRequest 클래스를 이용한 POST 전송하기.
  5. 2011.02.04 Fonts for ipad, iphone
  6. 2011.01.07 WPF의 datagrid 의 스타일 정의.
  7. 2011.01.04 PHP 에서 UTF-8 관련 문제.
  8. 2010.12.29 Stencil Routed K-Buffer
  9. 2010.12.26 Tile Map Editor
  10. 2010.12.22 OpentTK/WPF integration

2012년 11월 UDK 릴리즈 노트 중에서.

New Perforce Setup Wizard

  • Developers using the Perforce integration can walk through setting up a new Perforce server via the UDK installer.

Clean Starter Project Tool

  • Developers now have the option to start with a “clean” project with bare minimum code and content upon install.
  • This is a great way to begin development of a new game from scratch!
UDK 를 설치할때만 가능한 것들로서 입력된 프로젝트 이름으로 clean 상태로 인스톨을 한 뒤에 perforce 서버로 자동으로 add 해준다.

현재 설치파일중 한글 부분은 깨져서 메시지가 제대로 나오지 않는다. 씁.

Setting Up Configuration Files for a New Game Project


http://wiki.beyondunreal.com/UE3:Setting_Up_a_New_Game_Project_Tutorial_(UDK)


http://wiki.beyondunreal.com/UE3:Setting_Up_Configuration_Files_for_a_New_Game_Project_Tutorial_(UDK)



UDK 로 새 프로젝트 생성시 추가해야할 것들.




PHP에서 json post 를 처리하는 방법.

How to Handle JSon POST Request Using PHP


http://edwin.baculsoft.com/2011/12/how-to-handle-json-post-request-using-php/


On my last project, i need to create a php service using JSon to handle service requests from multiple clients. My PHP file would consume JSon string for its requests and produce JSon string as its responses.
Im not too familiar with PHP, but after sometime googling i’ve found a workaround. This is how i do it.

01<?php
02// JSon request format is :
03// {"userName":"654321@zzzz.com","password":"12345","emailProvider":"zzzz"}
04 
05// read JSon input
06$data_back = json_decode(file_get_contents('php://input'));
07 
08// set json string to php variables
09$userName = $data_back->{"userName"};
10$password = $data_back->{"password"};
11$emailProvider = $data_back->{"emailProvider"};
12 
13// create json response
14$responses = array();
15for ($i = 0; $i < 10; $i++) {
16    $responses[] = array("name" => $i, "email" => $userName . " " . $password . " " . $emailProvider);
17}
18 
19// JSon response format is :
20// [{"name":"eeee","email":"eee@zzzzz.com"},
21// {"name":"aaaa","email":"aaaaa@zzzzz.com"},{"name":"cccc","email":"bbb@zzzzz.com"}]
22 
23// set header as json
24header("Content-type: application/json");
25 
26// send response
27echo json_encode($responses);
28?>

This is the http header and body of request and response.

Hope it help others, have fun with JSon


지난글에서 C# 으로 post json 데이터를 날리는 경우에는

Content-Type 가 

application/x-www-form-urlencoded 

인 경우에는 $_POST[postData] 로 받아서 처리하면 되는데.


Content-Type 자체가 

application/json

인 경우에는 php 에서 위와 같이 처리한다.

[C#] HttpWebRequest 클래스를 이용한 POST 전송하기.



http://onlybalance.pe.kr/xe/?category=99&mid=tech&document_srl=378&sort_index=readed_count&order_type=desc


[C#] HttpWebRequest 클래스를 이용한 POST 전송하기
01.protected void SendSMS()
02.{
03.String[] messages = new String[6];
04.messages[0] = "행정과";         // 아이디
05.messages[1] = "암호";           // 암호
06.messages[2] = "11111111111";    // 보내는 사람 번호
07.messages[3] = "22222222222";    // 받는 사람 번호
08.messages[4] = "테스트 메시지";  // 메시지
09.messages[5] = "홍길동";         // 받는 사람 이름
10.String postData = String.Format("id={0}&pw={1}&sender={2}&receiver={3}&msg={4}&idreserve={5}", messages[0], messages[1], messages[2], messages[3], messages[4], messages[5]);
11. 
12.HttpWebRequest httpWebRequest = (HttpWebRequest) WebRequest.Create("http://localhost:38080/encoding/encoding.jsp");
13.// 인코딩 1 - UTF-8
14.byte[] sendData = UTF8Encoding.UTF8.GetBytes(postData);
15.httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=UTF-8";
16.// 인코딩 2 - EUC-KR
17.//byte[] sendData = Encoding.GetEncoding("EUC-KR").GetBytes(postData);
18.//httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=EUC-KR";
19.httpWebRequest.ContentType = "application/x-www-form-urlencoded; charset=utf-8";
20.httpWebRequest.Method = "POST";
21.// Set the content length of the string being posted.
22.httpWebRequest.ContentLength = sendData.Length;
23.Stream requestStream = httpWebRequest.GetRequestStream();
24.requestStream.Write(sendData, 0, sendData.Length);
25.requestStream.Close();
26.HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();
27.StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("EUC-KR"));    // Encoding.GetEncoding("EUC-KR")
28.string html = streamReader.ReadToEnd();
29.streamReader.Close();
30.httpWebResponse.Close();
31. 
32.text.Value = html;
33.}

This is an easy way to make a JSON POST request to a remote service using C#:

1
2
3
4
5
6
7
8
9
10
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);
request.Method = "POST";
request.ContentType = "application/json; charset=utf-8";
DataContractJsonSerializer ser = new DataContractJsonSerializer(data.GetType());
MemoryStream ms = new MemoryStream();
ser.WriteObject(ms, data);
String json = Encoding.UTF8.GetString(ms.ToArray());
StreamWriter writer = new StreamWriter(request.GetRequestStream());
writer.Write(json);
writer.Close();

Notice that in line 4 we create an instance of DataContractJsonSerializer (Assembly: System.ServiceModel.Web) and initialize it with the type of object we are serializing as JSON to send to the service. In lines 5 and 6 the serializer writes the object into a Stream. Line 7 transforms the Stream into an UTF-8 String (as the content-type) and finally in lines 8 to 10 we send the data to the service.


약간의 문제가 발생하게 되는데

x-www-form-urlencoded 방식의 경우에 get 방식의 id=value&id2=value2 같은 방식으로 처리된다. (텍스트로)

그래서 JSON 으로 변환된 문자열을 전송할 경우에 & 문자가 있으면 의도하지 않은 에러가 발생한다.


그래서 serialize 된 문자열에서 


string postData = string.Format("shot={0}", JsonConvert.SerializeObject(shot));

                postData = postData.Replace("&", "%26");

                //string postData = string.Format("shot=TTT", JsonConvert.SerializeObject(shot));

                query_string = "exec=updateshot";

                var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://shots.php?" + query_string);

                httpWebRequest.ContentType = "text/json";

                byte[] sendData = UTF8Encoding.UTF8.GetBytes(postData);

                httpWebRequest.ContentType = "application/x-www-form-urlencoded;charset=UTF-8";              

                httpWebRequest.Method = "POST";

                httpWebRequest.ContentLength = sendData.Length;


                Stream requestStream = httpWebRequest.GetRequestStream();

                requestStream.Write(sendData, 0, sendData.Length);

                requestStream.Close();


                HttpWebResponse httpWebResponse = (HttpWebResponse) httpWebRequest.GetResponse();


                StreamReader streamReader = new StreamReader(httpWebResponse.GetResponseStream(), Encoding.GetEncoding("UTF-8"));    // Encoding.GetEncoding("EUC-KR")

                string shot_id = streamReader.ReadToEnd();

                streamReader.Close();

                httpWebResponse.Close();


postData = postData.Replace("&", "%26");

처럼 처리해주면 에러를 피할 수 있다.



Fonts for ipad, iphone

http://www.michaelcritz.com/2010/04/02/fonts-for-ipad-iphone/


WPF의 datagrid 의 스타일 정의.


Datagridcell 의 스타일을 정의하는 부분.
이 소스는 원래 cell의 Verticlal alignment 등을 사용하기 위해서 만들었는데 menuitem 도 추가를 했다.
일반적인 사용으로 Click="test" 같은 방식으로 menuitem 을 사용하면 xml 파싱 에러가 발생한다.
Style 정의에서는 이런식으로 사용 할 수 없다. 그래서 위 그림과 같이 event handler 를 사용했다.

'OLD POSTS' 카테고리의 다른 글

[C#] HttpWebRequest 클래스를 이용한 POST 전송하기.  (0) 2012.04.26
Fonts for ipad, iphone  (0) 2011.02.04
PHP 에서 UTF-8 관련 문제.  (0) 2011.01.04
Stencil Routed K-Buffer  (0) 2010.12.29
Tile Map Editor  (0) 2010.12.26

PHP 에서 UTF-8 관련 문제.

기존의 euc-kr 등의 파일들을 UTF-8 로 컨버팅해서 작업을 할 경우에
UTF-8 로 컨버팅된 파일 앞에 BOM 이 붙게 된다.


뭐 unicode 에서는 BOM이 붙는게 정석이긴 한데. 
문제는 php 파일의 맨 앞에 3바이트의 BOM 이 있으면 그 3바이트를 그대로
출력을 한다.

일반 html 에서는 눈에 잘 안띄어서 잘 모를수도 있으나
xmlrpc 서버 같은 경우에도 맨 앞에 붙어서 출력이 되는 바람에
client 에서 제대로 parsing 을 못하는 아주 어이없는 상황이 
계속 발생한다.

php 파일들은 UTF-8 NO BOM 인코딩으로 새로 저장을 다 해주면 해결 할 수 있다.

'OLD POSTS' 카테고리의 다른 글

Fonts for ipad, iphone  (0) 2011.02.04
WPF의 datagrid 의 스타일 정의.  (0) 2011.01.07
Stencil Routed K-Buffer  (0) 2010.12.29
Tile Map Editor  (0) 2010.12.26
OpentTK/WPF integration  (0) 2010.12.22

Stencil Routed K-Buffer

Nvidia direct3D 10 예제중 하나.
잘 봐둬야 할 쉐이더중 하나.

XNA 혹은 DirectX로 한번 새로 구현해 볼만한 것.


'OLD POSTS' 카테고리의 다른 글

WPF의 datagrid 의 스타일 정의.  (0) 2011.01.07
PHP 에서 UTF-8 관련 문제.  (0) 2011.01.04
Tile Map Editor  (0) 2010.12.26
OpentTK/WPF integration  (0) 2010.12.22
ATI Rendermonkey  (0) 2010.12.20

Tile Map Editor


http://www.mapeditor.org/


'OLD POSTS' 카테고리의 다른 글

PHP 에서 UTF-8 관련 문제.  (0) 2011.01.04
Stencil Routed K-Buffer  (0) 2010.12.29
OpentTK/WPF integration  (0) 2010.12.22
ATI Rendermonkey  (0) 2010.12.20
FX Composer 2.5 Sample Projects  (0) 2010.12.20

OpentTK/WPF integration

WPF와 OpenGL 을 통합하는 내용임.
정리가 좀 잘된 편인듯하다.

OpenGL 테스트용으로 이 소스를 가지고 사용하면 좋을듯함.



OpenGL Toolkit for C#

'OLD POSTS' 카테고리의 다른 글

Stencil Routed K-Buffer  (0) 2010.12.29
Tile Map Editor  (0) 2010.12.26
ATI Rendermonkey  (0) 2010.12.20
FX Composer 2.5 Sample Projects  (0) 2010.12.20
Integrating XNA 4.0 and WPF  (0) 2010.12.17
prev 1 2 3 4 5 6 next