0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

unity > unityApp > udp echo server (delay付き) > Convert.ToInt16(string) / int.Parse()との違い / IPアドレス取得 / Thread.Sleep(msec)

Last updated at Posted at 2015-08-29
実装
Unity 5.1.2-f on MacOS X 10.8.5

UDPポートでエコーバックするソフト。

Scene_unity_-150829-udpEcho-Android__Personal.jpg

以下の機能を持つ。

  • port 6000で受信した文字列をそのまま返信する
  • 返信時は指定したdelay(msec)の待ちを発生させてから返信する
    • 通信回線の悪い状況の再現 (参考)
  • ソフト起動直後にポート6000にて通信ができるようになる

github
callgraph @ mindmup

このアプリ実装で以下の方法が整理できた

  • textからintへの変換 > Convert.ToInt16(string);
    • int.Parse(string)もあるが、Conver.ToInt16(string)がいいとのこと (参考)
    • Convert.ToInt16()を使うにはusing System
  • IPアドレスの取得 > getMyIPAddress()にて実装
  • Thread.Sleep(20)しないと androidではunity splash screenから進まない. Macでは問題なかった

(追記 2017/04/19)
https://www.youtube.com/watch?v=v-1k7b9L-Sw&list=PLUyYwyJA_WfQd5zeCU890TDFQAqboekyc#t=2.856409
の15:20あたりでもint.Parse()Convert.ToInt16()が出てくる。

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?