This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // チャットメッセージコレクションを取得 | |
| var collection = database.GetCollection<ChatMessage>("chat_message"); | |
| // 格納するデータを生成 | |
| var chatmsg = new ChatMessage(); | |
| chatmsg.UserName = msg.username; | |
| chatmsg.Comment = msg.comment; | |
| // awaitで非同期インサート! | |
| await collection.InsertOneAsync(chatmsg); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // chatapp用DBを取得します。 | |
| client.GetDatabase("chatapp"); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| MongoUrl url = new MongoUrl( string.Format("mongodb://{0}:{1}", addr, port) ); | |
| var client = new MongoClient(url); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ドッカーコンテナのリンク機能経由で渡ってきた環境変数を取得 | |
| var dbaddr = System.Environment.GetEnvironmentVariable("DB_PORT_27017_TCP_ADDR"); | |
| var dbport = int.Parse(System.Environment.GetEnvironmentVariable("DB_PORT_27017_TCP_PORT")); | |
| // DBと接続 | |
| Storage.SetMongo(dbaddr, dbport); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ./csbuild build |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ mcs -out:app.exe -recurse:'*.cs' -main:App -r:websocket-sharp.dll -r:MongoDB.Driver.dll -r:MongoDB.Bson.dll -r:MongoDB.Driver.Core.dll -r:MongoDB.Driver.Legacy.dll -r:Newtonsoft.Json.dll |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./csbuild install nuget 'WebSocketSharp -Pre' | |
| $ ./csbuild install nuget 'Newtonsoft.Json -Pre' | |
| $ ./csbuild install nuget 'mongocsharpdriver' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ ./csbuild install nuget "<package name>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # まずはchatapp用ドッカーコンテナに入ります。 | |
| $ docker exec -it gchat_web_1 bash -l | |
| # nuget.exeをダウンロード | |
| $ cd /code | |
| $ curl -L -O https://nuget.org/nuget.exe |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| $ supervisorctl start chatapp |