| 142 | } |
| 143 | |
| 144 | bool AFCMsgModule::SendMsg(std::shared_ptr<AFINet>& pNet, const int src_bus, const int target_bus, const int msg_id, |
| 145 | const google::protobuf::Message& msg, const AFGUID& guid) |
| 146 | { |
| 147 | if (pNet == nullptr) |
| 148 | { |
| 149 | ARK_LOG_ERROR( |
| 150 | "net is invalid, src_bus={} target_bus={} msg_id={} actor_id={}", src_bus, target_bus, msg_id, guid); |
| 151 | return false; |
| 152 | } |
| 153 | |
| 154 | std::string msg_data; |
| 155 | if (msg.SerializeToString(&msg_data)) |
| 156 | { |
| 157 | ARK_LOG_ERROR("msg serializing failed, src_bus={} target_bus={} msg_id={} actor_id={}", src_bus, target_bus, |
| 158 | msg_id, guid); |
| 159 | return false; |
| 160 | } |
| 161 | |
| 162 | AFSSMsgHead head; |
| 163 | head.id_ = msg_id; |
| 164 | head.length_ = msg_data.length(); |
| 165 | head.actor_id_ = guid; |
| 166 | head.src_bus_ = src_bus; |
| 167 | head.dst_bus_ = target_bus; |
| 168 | |
| 169 | return pNet->SendMsg(&head, msg_data.c_str(), 0); // do not need session id |
| 170 | } |
| 171 | |
| 172 | } // namespace ark |