yangg | a4b6f5d | 2014-12-17 15:53:12 -0800 | [diff] [blame] | 1 | /* |
| 2 | * |
| 3 | * Copyright 2014, Google Inc. |
| 4 | * All rights reserved. |
| 5 | * |
| 6 | * Redistribution and use in source and binary forms, with or without |
| 7 | * modification, are permitted provided that the following conditions are |
| 8 | * met: |
| 9 | * |
| 10 | * * Redistributions of source code must retain the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer. |
| 12 | * * Redistributions in binary form must reproduce the above |
| 13 | * copyright notice, this list of conditions and the following disclaimer |
| 14 | * in the documentation and/or other materials provided with the |
| 15 | * distribution. |
| 16 | * * Neither the name of Google Inc. nor the names of its |
| 17 | * contributors may be used to endorse or promote products derived from |
| 18 | * this software without specific prior written permission. |
| 19 | * |
| 20 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 21 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 22 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 23 | * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 24 | * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 25 | * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 26 | * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 27 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 28 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 29 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 30 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 31 | * |
| 32 | */ |
| 33 | |
Craig Tiller | c416577 | 2015-02-11 10:51:04 -0800 | [diff] [blame] | 34 | #include <grpc++/server_context.h> |
Craig Tiller | 0156752 | 2015-02-11 21:08:49 -0800 | [diff] [blame] | 35 | #include <grpc++/impl/call.h> |
Craig Tiller | 854a30c | 2015-02-11 11:44:10 -0800 | [diff] [blame] | 36 | #include <grpc/grpc.h> |
| 37 | #include "src/cpp/util/time.h" |
yangg | a4b6f5d | 2014-12-17 15:53:12 -0800 | [diff] [blame] | 38 | |
Craig Tiller | 854a30c | 2015-02-11 11:44:10 -0800 | [diff] [blame] | 39 | namespace grpc { |
| 40 | |
Craig Tiller | 9dcb0f8 | 2015-02-11 15:36:31 -0800 | [diff] [blame] | 41 | ServerContext::ServerContext(gpr_timespec deadline, grpc_metadata *metadata, |
| 42 | size_t metadata_count) |
| 43 | : deadline_(Timespec2Timepoint(deadline)) { |
Craig Tiller | 854a30c | 2015-02-11 11:44:10 -0800 | [diff] [blame] | 44 | for (size_t i = 0; i < metadata_count; i++) { |
Craig Tiller | 9dcb0f8 | 2015-02-11 15:36:31 -0800 | [diff] [blame] | 45 | client_metadata_.insert(std::make_pair( |
| 46 | grpc::string(metadata[i].key), |
| 47 | grpc::string(metadata[i].value, |
| 48 | metadata[i].value + metadata[i].value_length))); |
Craig Tiller | 854a30c | 2015-02-11 11:44:10 -0800 | [diff] [blame] | 49 | } |
| 50 | } |
| 51 | |
Craig Tiller | 3d6ceb6 | 2015-02-12 14:33:54 -0800 | [diff] [blame] | 52 | ServerContext::~ServerContext() { |
| 53 | if (call_) { |
| 54 | grpc_call_destroy(call_); |
| 55 | } |
| 56 | } |
| 57 | |
Craig Tiller | 854a30c | 2015-02-11 11:44:10 -0800 | [diff] [blame] | 58 | } // namespace grpc |